老师我垂直居中跟水平居中还是不怎么会

来源:4-4 课程总结

慕瓜8136058

2017-09-19 20:40:35

<!DOCTYPE html>

<html>

    <head>

        <meta charset="UTF-8">

        <title>文本样式</title>

        <style type="text/css">

           /*写出CSS样式*/

           div{

               width:100%;

               height:80px;

               background-color:#eee;

               text-align:center;

               line-height:5em;

           }

           .one1{font-size:2em;}

           .one2{color:red;text-decoration:underline;}

        </style>

    </head>

    <body>

          <!--写出html代码-->

          <div><span class="one"><img src="img/css3.jpg"/></span><span class="one1">Css层叠样式表</span><span class="one2">cacacaca vavav babab</span></div>

    </body>

</html>


写回答

2回答

小丸子爱吃菜

2017-09-20

1、 单词针对于“CSS层叠样式表”居中显示,实现这个效果,可以给.one添加属性   vertical-align: middle;

2、text-align 属性规定元素中的文本的水平对齐方式。

3、height与line-height值一样,能确保元素在垂直方向居中对齐。

4、你的line-height值尽量与line-height值一样,是像素都是像素,是em都是em。

祝学习愉快!

0

慕先生1465952

2017-09-20

这属于单行内容水平垂直居中对齐,设置标签内元素line-height=height。

0

0 学习 · 36712 问题

查看课程