我想将这三个图像对齐并使其响应,以便将它们叠加在另一个之下,但我无法弄清楚为什么容器关于____总是略微向左移动......?这是Codepen链接:http://codepen.io/anon/pen/PbpMbj
section.about {
font-family: 'Montserrat', sans-serif;
text-align: center;
}
.small__title {
font-family: 'Kaushan Script', cursive;
font-size: 16px;
}
.big__title {
font-weight: bold;
font-size: 20px;
}
.description {
width: 700px;
margin: 0 auto;
font-size: 12px;
}
.about__images {
max-width: 780px;
margin: 0 auto;
}
.about__inner {
margin-top: 60px;
float: left;
}
.about__inner img {
max-width: 240px;
margin-right: 20px;
}

<section class="about">
<h5 class="small__title">lorem</h5>
<h4 class="big__title">Lorem lorem</h4>
<hr class="horizontal__rule">
<p class="description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae commodi nisi aut animi, excepturi impedit dicta natus culpa. Veniam atque sapiente assumenda fugiat tempore ipsam eos quae</p>
<div class="container">
<div class="row about__images">
<div class="about__inner first">
<img src="https://placeholdit.imgix.net/~text?txtsize=36&txt=383%C3%97262&w=383&h=262" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>LOREM IPSUM</p>
</div>
</div>
<div class="about__inner">
<img src="https://placeholdit.imgix.net/~text?txtsize=36&txt=383%C3%97262&w=383&h=262" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>LOREM IPSUM</p>
</div>
</div>
<div class="about__inner">
<img src="https://placeholdit.imgix.net/~text?txtsize=36&txt=383%C3%97262&w=383&h=262" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>LOREM IPSUM</p>
</div>
</div>
</div>
</div>
</section>
&#13;
答案 0 :(得分:2)
由于您已经在使用 Bootstrap ,因此只需使用其默认类来更好地对齐:
section.about {
font-family: 'Montserrat', sans-serif;
text-align: center;
}
.small__title {
font-family: 'Kaushan Script', cursive;
font-size: 16px;
}
.big__title {
font-weight: bold;
font-size: 20px;
}
.description {
width: 700px;
margin: 0 auto;
font-size: 12px;
}
/*.about__images,
.about__images * {
box-sizing: content-box;
}*/
.about__images {
max-width: 780px;
margin: 0 auto;
}
.about__inner {
margin-top: 60px;
}
.about__inner img {
max-width: 100%;
}
&#13;
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" />
<section class="about">
<h5 class="small__title">lorem</h5>
<h4 class="big__title">Lorem lorem</h4>
<hr class="horizontal__rule">
<p class="description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae commodi nisi aut animi, excepturi impedit dicta natus culpa. Veniam atque sapiente assumenda fugiat tempore ipsam eos quae</p>
<div class="container">
<div class="about__images">
<div class="row">
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=36&txt=383%C3%97262&w=383&h=262" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>LOREM IPSUM</p>
</div>
</div>
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=36&txt=383%C3%97262&w=383&h=262" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>LOREM IPSUM</p>
</div>
</div>
<div class="about__inner col-md-4">
<img src="https://placeholdit.imgix.net/~text?txtsize=36&txt=383%C3%97262&w=383&h=262" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>LOREM IPSUM</p>
</div>
</div>
</div>
</div>
</div>
</section>
&#13;
答案 1 :(得分:0)
尝试使用flex。 添加
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column-reverse;
flex-direction: column-reverse;
到您的.about__images
班级
section.about {
font-family: 'Montserrat', sans-serif;
text-align: center;
}
.small__title {
font-family: 'Kaushan Script', cursive;
font-size: 16px;
}
.big__title {
font-weight: bold;
font-size: 20px;
}
.description {
width: 700px;
margin: 0 auto;
font-size: 12px;
}
.about__images {
max-width: 780px;
margin: 0 auto;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: column-reverse;
flex-direction: column-reverse;
}
.about__inner {
margin-top: 60px;
float: left;
}
.about__inner img {
max-width: 240px;
margin-right: 20px;
}
&#13;
<section class="about">
<h5 class="small__title">lorem</h5>
<h4 class="big__title">Lorem lorem</h4>
<hr class="horizontal__rule">
<p class="description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Beatae commodi nisi aut animi, excepturi impedit dicta natus culpa. Veniam atque sapiente assumenda fugiat tempore ipsam eos quae</p>
<div class="container">
<div class="row about__images">
<div class="about__inner first">
<img src="https://placeholdit.imgix.net/~text?txtsize=36&txt=383%C3%97262&w=383&h=262" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>LOREM IPSUM</p>
</div>
</div>
<div class="about__inner">
<img src="https://placeholdit.imgix.net/~text?txtsize=36&txt=383%C3%97262&w=383&h=262" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>LOREM IPSUM</p>
</div>
</div>
<div class="about__inner">
<img src="https://placeholdit.imgix.net/~text?txtsize=36&txt=383%C3%97262&w=383&h=262" alt="">
<div class="about__inner--overlay">
<i class="fa fa-user" aria-hidden="true"></i>
<p>LOREM IPSUM</p>
</div>
</div>
</div>
</div>
</section>
&#13;
答案 2 :(得分:0)
您可以使用flexbox将图像居中放置,并添加媒体查询以使其在一定宽度下堆叠。
.about__images {
max-width: 780px;
margin: 60px auto 0;
display: flex;
flex-direction: row;
justify-content: space-around;
}
@media (max-width:1000px) {
.about__images {
display: block;
}
.about__inner {
text-align: center;
}
}
.about__inner {
}
.about__inner img {
max-width: 240px;
}
这是使用Codepen上的flexbox的代码。