mar*_*cks 12 css twitter-bootstrap twitter-bootstrap-3
我正在尝试使用Bootstrap 3创建一个登陆页面.我想要一个全宽度列中的顶部图像,其下面有三个图像,没有边距或边框,因此图像可以无缝连接.
我可以靠近但是当我缩小视口时,顶部图像和它下面的图像之间会打开一个空间.
这是URL:
这是我的代码:
HTML:
<div class="container-fluid">
<div class="row">
<div class="landing-col col-xs-12"></div>
</div>
<div class="row">
<div class="first-col col-sm-4"></div>
<div class="second-col col-sm-4"></div>
<div class="third-col col-sm-4"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
.landing-col {
background: url('../images/99.jpg') no-repeat;
-webkit-background-size: 100% auto;
-moz-background-size: 100% auto;
-o-background-size: 100% auto;
background-size: 100% auto;
height: 500px; }
.first-col {
background: url('../images/44.jpg') no-repeat;
-webkit-background-size: 100% auto;
-moz-background-size: 100% auto;
-o-background-size: 100% auto;
background-size: 100% auto;
height: 300px;
}
.second-col {
background: url('../images/33.jpg') no-repeat;
-webkit-background-size: 100% auto;
-moz-background-size: 100% auto;
-o-background-size: 100% auto;
background-size: 100% auto;
height: 300px;
}
.third-col {
background: url('../images/22.jpg') no-repeat;
-webkit-background-size: 100% auto;
-moz-background-size: 100% auto;
-o-background-size: 100% auto;
background-size: 100% auto;
height: 300px;
}
Run Code Online (Sandbox Code Playgroud)
我尝试使用100%的最小宽度和最大宽度,但它们对我不起作用.
可能的方法是使用媒体查询来获取当前网格的精确宽度,并将其中的图像宽度设置为该宽度.这可能吗?
Rak*_*hat 14
您可以将块元素与背景图像一起使用,其中高度通过padding-bottom设置为百分比值
.img {
margin-right: -15px; // Remove right gap
margin-left: -15px; // Remove left gap
padding-bottom: 62.5%; // ratio is 16:10
background-position: 50% 50%;
background-repeat: no-repeat;
background-size: cover;
}
Run Code Online (Sandbox Code Playgroud)
实施例中Codepen
或使用img元素(在这种情况下,您的图像应具有相同的尺寸)
实施例中Codepen
我们试试这些:
col-md-*到每个列中landing-col高度降低到300pxHTML
<div class="container-fluid">
<div class="row">
<div class="landing-col col-md-12 col-xs-12"></div>
<div class="first-col col-md-4 col-sm-4"></div>
<div class="second-col col-md-4 col-sm-4"></div>
<div class="third-col col-md-4 col-sm-4"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.landing-col {
background: url('http://sample.trainingdata.com.au/images/99.jpg') no-repeat;
-webkit-background-size: 100% auto;
-moz-background-size: 100% auto;
-o-background-size: 100% auto;
background-size: 100% auto;
height: 300px;
margin:0;
padding:0px;
}
Run Code Online (Sandbox Code Playgroud)
在这里演示=> http://fiddle.jshell.net/nobuts/7x0rpn5y/12/show/light/.
| 归档时间: |
|
| 查看次数: |
33897 次 |
| 最近记录: |