如果你全屏观看演示,我试图调整每个div的所有内部内容 - 例如您会注意到中间青色div的内容与第一个和第三个青色div的内容不一致。
很难解释,但看看中间青色div中的图标与其他图标的位置。如果每个div内部有不同数量的文本,我怎样才能使内部内容与其他青色div垂直对齐?
.sections {
background: #f2f2f2;
width: 100%;
height: auto;
text-align: center;
padding: 100px 10%;
box-sizing: border-box;
}
#foster-cta-wrap {
background: yellow;
display: flex;
justify-content: space-evenly;
flex-direction: row;
align-items: center;
flex-flow: row wrap;
}
.foster-cta {
box-sizing: border-box;
width: 250px;min-width: 250px;
height: 200px;
background: cyan;
border: 1px solid grey;
margin-top: 30px;
flex-direction: column;
justify-content: space-evenly;
align-items: center;
display: inline-flex;
}
.foster-top {
display: block;
font-size: 30px;
}
.foster-middle {
display: block;
text-transform: uppercase;
font-size: 22px;
font-weight: 400;
}
.foster-bottom {
display: block;
font-weight: 300;
font-size: 16px;
}
.foster-cta:hover {
background: lightgreen;
cursor: pointer;
}
.foster-top a:link, .foster-top a:visited, .foster-middle a:link, .foster-middle a:visited, .foster-bottom a:link, .foster-bottom a:visited {
text-decoration: none;
color: #333;
}
<section class="sections">
<article id="foster-cta-wrap">
<nav class="foster-cta">
<span class="foster-top">icon</span>
<span class="foster-middle"><a href="#">search engine optimisation</a></span>
<span class="foster-bottom">increase the rankings in search results.</span>
</nav><!--
--><nav class="foster-cta">
<span class="foster-top">icon</span>
<span class="foster-middle"><a href="#">SEO</a></span>
<span class="foster-bottom">increase the rankings in search results.</span>
</nav><!--
--><nav onclick="location.href='#';" class="foster-cta">
<span class="foster-top">icon</span>
<span class="foster-middle"><a href="#">search engine optimisation</a></span>
<span class="foster-bottom">increase the rankings in search results.</span>
</nav>
</article>
</section>
答案 0 :(得分:1)
.sections {
background: #f2f2f2;
width: 100%;
height: auto;
text-align: center;
padding: 100px 10%;
box-sizing: border-box;
}
#foster-cta-wrap {
background: yellow;
display: flex;
justify-content: space-evenly;
flex-direction: row;
align-items: center;
flex-flow: row wrap;
}
.foster-cta {
box-sizing: border-box;
width: 250px;min-width: 250px;
height: 200px;
background: cyan;
border: 1px solid grey;
margin-top: 30px;
text-align: center;
}
.foster-top {
display: block;
font-size: 30px;
padding: .5em;
}
.foster-middle {
display: block;
text-transform: uppercase;
font-size: 22px;
font-weight: 400;
}
.foster-bottom {
display: block;
font-weight: 300;
font-size: 16px;
}
.foster-cta:hover {
background: lightgreen;
cursor: pointer;
}
.foster-top a:link, .foster-top a:visited, .foster-middle a:link, .foster-middle a:visited, .foster-bottom a:link, .foster-bottom a:visited {
text-decoration: none;
color: #333;
}
&#13;
<section class="sections">
<article id="foster-cta-wrap">
<nav class="foster-cta">
<span class="foster-top">icon</span>
<span class="foster-middle"><a href="#">search engine optimisation</a></span>
<span class="foster-bottom">increase the rankings in search results.</span>
</nav>
<nav class="foster-cta">
<span class="foster-top">icon</span>
<span class="foster-middle"><a href="#">SEO</a></span>
<span class="foster-bottom">increase the rankings in search results.</span>
</nav>
<nav onclick="location.href='#';" class="foster-cta">
<span class="foster-top">icon</span>
<span class="foster-middle"><a href="#">search engine optimisation</a></span>
<span class="foster-bottom">increase the rankings in search results.</span>
</nav>
</article>
</section>
&#13;
我会这样做:我删除了.foster-cta
上的所有flex格式,并将其替换为text-align: center;
。然后,我添加了填充到.foster-top
以使其看起来更好,而不是与其他文本联系。标题现在被推向主标题,但可以通过为其中任何一个设置padding
/ margin
值来解决此问题。