【发布时间】:2015-09-14 11:57:08
【问题描述】:
我正在尝试对齐两个 div 中的两个图像。这是两张图片,它们的大小、分辨率相同,并且在 Photoshop 中对齐非常完美:
但是当我像这样在 index.html 中引用它们时:
<!-- Intro Header -->
<div class="intro">
<div class="intro-body">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h2>ssss</h1>
</div>
</div>
</div>
</div>
</div>
<!-------acerca---------->
<div id="acerca" class="acerca">
<div class="acerca-body">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<h2>Acerca de Cssss</h2>
</div>
</div>
</div>
</div>
</div>
使用完全相同的 css 类:
.intro {
display: table;
width: 100%;
height: auto;
padding: 100px 0;
text-align: center;
color: #fff;
background: url(http://i.imgur.com/jDhQ6PP.jpg?1) no-repeat bottom center scroll;
background-color: #000;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
.intro .intro-body {
display: table-cell;
vertical-align: middle;
}
.intro .intro-body .brand-heading {
font-size: 40px;
}
.intro .intro-body .intro-text {
font-size: 18px;
}
.acerca {
display: table;
width: 100%;
height: auto;
padding: 100px 0;
text-align: center;
color: #fff;
background: url(http://i.imgur.com/raMFNcc.png?1) no-repeat bottom center scroll;
background-color: #000;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}
.acerca .acerca-body {
display: table-cell;
vertical-align: middle;
}
.acerca .acerca-body .brand-heading {
font-size: 40px;
}
.acerca .acerca-body .acerca-text {
font-size: 18px;
}
并且图像没有对齐,正如您在这张图片中看到的那样:
由于缺少声望点,我无法发布图片,这只是我的第二个问题。
有人知道如何对齐它们吗?谢谢。
JSfiddle:https://jsfiddle.net/uyo35tuf/
【问题讨论】:
-
把这个放在 jsfiddle 上并提供一个链接以便我们提供帮助:)
-
你能在 CSS 中发布正确的图片 URL 吗?它将帮助我们更好地检查。
-
@ManojKumar 完成......谢谢!
-
@LloanAlas jsfiddle.net/uyo35tuf
-
您是否尝试过使用
background-position: center;?