em的继承性问题

常规情况下em继承父级字体大小

但是当元素自身声明font-size时 元素内的em是继承自元素内的font-size的

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    .main{
        font-size: 16px;
    }
    .floatem{
        /* float: left; */
        font-size: 2em;
        /* position: relative; */
        line-height: 3.5em;
    padding: 0.75em 2.5em;
    }
    </style>
</head>
<body>
    <div class="main">
        <div class="floatem">
            你好

        </div>
    </div>
</body>
</html>

  以上为验证代码

    验证浏览器为谷歌浏览器,不排除其他浏览器的差异性

posted @ 2019-03-25 21:06  monstermr  阅读(526)  评论(0编辑  收藏  举报