作为序言:我遇到过许多其他解决方案,但没有找到一个可行的解决方案的运气。我目前正在使用此答案将文本与div的底部对齐,但是没有任何运气。
无论出于何种原因,我的vertical-align: bottom;
属性完全不会影响页面的CSS。如果我想使文本与图像底部对齐,这是怎么做的?
index.html
<body>
<div class="header">
<div class="container">
<div class="pull-left">
<a href="">What's This?</a>
</div>
<img src="http://placehold.it/75x75" />
<div class="pull-right">
<a href="">About</a>
</div>
</div>
</div>
<!-- Modules -->
<!-- Controllers -->
<!-- Services -->
</body>
main.css
html, body {
margin: 0;
padding: 0;
font-family: 'Open Sans', sans-serif;
}
body {
background-color: #FF3B4E;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
.header {
background-color: white;
text-align: center;
height: 125px;
}
.header img {
margin: 25px 0;
}
.header .pull-left{
border: 1px solid black;
height: 75px;
margin-top: 25px;
top: 0;
line-height: 75px;
vertical-align: bottom;
}
.header .pull-right {
border: 1px solid black;
height: 75px;
margin-top: 25px;
top: 0;
line-height: 75px;
vertical-align: bottom;
}
解决此问题时,我周围有框pull-left
并且pull-right
出于视觉目的。一旦我可以使文本正确对齐,就将删除边框。谢谢你的帮助!
jsfiddle:https ://jsfiddle.net/rtc498uk/
编辑:我的目标是使文本像这样对齐:
.pull-right a, .pull-left a{
line-height: 1em;
vertical-align: bottom;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句