前端冷知识

1.text-align

这个属性是用来对齐行内内容的,所以,应该对块级内容起作用

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <style>
         .demo{
             width:200px;
             background:purple;
             text-align:center;
             height:100px;
         }

          .demo1{
             width:100px;
             height:80px;
             display:inline;
             background:blue;
             text-align:center;
         }
     </style>
</head>
<body>
    <div class="demo">
      <div class="demo1">
      
123
     </div> </div> </body> </html>

按照标准的css规范,这里面demo1如果不加入display:inline是不会居中对齐的,

 但在IE6/7及IE8混杂模式中,text- align:center可以使块级元素也居中对齐。其他浏览器中,text-align:center仅作用于行内内容上。

原文地址:https://www.cnblogs.com/beileye888/p/7482943.html