链接到实时版本:http://45.55.186.46/test/
我有一组部分,我想使用bottom属性垂直对齐图像。但是当前列的高度不同。当我尝试向所有父标签添加height:100%属性时,图像会放大并溢出该部分。任何帮助,将不胜感激。
谢谢
的HTML
<div class = "container-fluid lookbook sectionContainer">
<div class = "row lookbookRow">
<div class = "col-md-6">
<img class = "img-responsive lookbook1" src = "img/lookbook1.jpg" alt = "lookbook1" >
</div>
<div class = "col-md-6">
<div class = "row">
<div class = "col-md-6">
<img class = "img-responsive desktopOnly lookbook2" src = "img/lookbook2.jpg" alt = "lookbook2" >
</div>
<div class = "col-md-6 lookbookText section">
<h1> <strong> LEARN THE <br> PRINT RULES </strong></h1>
<h2> <strong> Take a lesson in 'how to wear print' from fashion aficionado, TV presenter and newly crowned 'Print Princess', Laura Jackson. </strong></h2>
<div style = "text-align: center">
<button id = "lookbookButton"> <strong> VIEW THE LOOKBOOK > </strong></button>
</div>
</div>
</div>
<div class = "row secondaryImages">
<div class = "col-xs-7">
<img class = "img-responsive" src = "img/lookbook3.jpg" alt = "lookbook3">
</div>
<div class = "col-xs-5">
<img class = "img-responsive lookbook4" src = "img/lookbook4.jpg" alt = "lookbook4">
</div>
</div>
</div>
</div>
</div>
CSS节
.lookbook {
padding-top: 10px;
padding-left: 0px;
padding-right: 0px;
}
#lookbookButton {
font-family: "chantilly-light", sans-serif;
text-align: center;
background-color: #C3D5EF;
border-radius: 0px;
border: none;
color: #000000;
letter-spacing: 2px;
padding:15px;
font-size: 22px;
}
.lookbookText {
height: 100%;
}
.lookbook2 {
height: 400px;
}
.lookbookRow {
margin: 0px;
}
.lookbook4 {
bottom: -100px;
}
.secondaryImages {
padding-top: 20px;
}
全球CSS
html,body
{
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
overflow-x: hidden;
}
.bannerRow h2 {
font-family: "chantilly-light", sans-serif;
letter-spacing: 1px;
text-align: center;
font-size: 24px;
color: #333333;
padding-top: 10px;
padding-bottom: 10px;
}
.bannerRow h1 {
font-family: "chantilly-light", sans-serif;
text-align: center;
font-size: 49px;
letter-spacing: 5px;
color: #345e91;
}
.sectionContainer {
margin-top: 20px;
}
.section h1 {
font-family: "chantilly-light", sans-serif;
text-align: center;
font-size: 40px;
letter-spacing: 8px;
color: #000000;
}
.section h2 {
font-family: "chantilly-light", sans-serif;
text-align: center;
font-size: 24px;
padding-bottom: 20px;
letter-spacing: 3px;
color: #000000;
}
.mobileOnly {
display:none;
}
最佳答案
在您的测试页上做了一些实验,并获得了足够的CSS唯一解决方案。将要垂直对齐的.col- *类设置为以下CSS的底部:
float: none;
display: inline-block;
vertical-align: bottom;
然后将父行设置为
display: table;
,以弥补内联块创建的额外填充,并且应正确对齐。对于您一些较复杂的行,仍然需要进行一些细化处理,但效果似乎不错。关于html - 自举相等的列高(使用底部垂直对齐图像),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30103047/