css 怎么样水平垂直居中一个元素?
<div style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">水平垂直居中在 Web 上的运用<span style="color: black;">能够</span>说是随处可见,<span style="color: black;">例如</span>一个 Icon 图标在其容器中水平垂直居中,一个标题在导航栏中水平垂直居中。 CSS 中<span style="color: black;">能够</span>实现水平垂直居中的技术<span style="color: black;">方法</span><span style="color: black;">亦</span>有<span style="color: black;">非常多</span>种,<span style="color: black;">最少</span>不会少于十种<span style="color: black;">区别</span>的技术<span style="color: black;">方法</span>。<span style="color: black;">不外</span>,<span style="color: black;">这儿</span><span style="color: black;">咱们</span>主讲 Flexbox <span style="color: black;">怎样</span>实现水平垂直居中。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">首要</span>,水平垂直居中<span style="color: black;">平常</span>的两效果有两种,单行(或单列)水平垂直居中和多行(或多列)水平垂直居中。它对应的 HTML 结构可能会像下面<span style="color: black;">这般</span>:</p>
<div style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;"><!-- 单行(或单列)水平垂直居中 --></span>
<span style="color: black;"><</span><span style="color: black;">div</span> <span style="color: black;">class</span><span style="color: black;">=</span><span style="color: black;">"container container--single"</span><span style="color: black;">></span>
<span style="color: black;"><</span><span style="color: black;">img</span> <span style="color: black;">src</span><span style="color: black;">=</span><span style="color: black;">"avatar.png"</span> <span style="color: black;">alt</span><span style="color: black;">=</span><span style="color: black;">"<span style="color: black;">必须</span>在容器中水平垂直居中"</span> <span style="color: black;">/></span>
<span style="color: black;"></</span><span style="color: black;">div</span><span style="color: black;">></span>
<span style="color: black;"><!-- 多行(或多列)水平垂直居中 --></span>
<span style="color: black;"><</span><span style="color: black;">div</span> <span style="color: black;">class</span><span style="color: black;">=</span><span style="color: black;">"container container--multiple"</span><span style="color: black;">></span>
<span style="color: black;"><</span><span style="color: black;">imag</span> <span style="color: black;">src</span><span style="color: black;">=</span><span style="color: black;">"avatar"</span> <span style="color: black;">alt</span><span style="color: black;">=</span><span style="color: black;">"<span style="color: black;">咱们</span>要水平垂直居中"</span> <span style="color: black;">/></span>
<span style="color: black;"><</span><span style="color: black;">h3</span><span style="color: black;">></span>大漠
</div>
</span></div>
楼主听话,多发外链好处多,快到碗里来!外链论坛 http://www.fok120.com/ 期待你更多的精彩评论,一起交流学习。 seo常来的论坛,希望我的网站快点收录。 楼主的文章深得我心,表示由衷的感谢! 交流如星光璀璨,点亮思想夜空。 系统提示我验证码错误1500次 \~゛,
页:
[1]