css面试题

73 阅读1分钟

CSS哪些样式是可以继承的?

可以继承的样式:

有关于文字样式的都可以继承:

image.png

line-height要注意的地方

line-height: 200px 直接继承

line-height: 1.5 根据自己的字体大小计算

line-height:200% 根据父级的字体大小计算

代码

<html>

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>项目部王广为</title>
</head>
<style>
    body {
        font-size: 20px;
        color: red;
        font-style: italic;
        font-weight: bold;
        text-indent: 2em;
        text-align: center;
        word-spacing: 5px;
        letter-spacing: 10px;
        /* line-height: 200px; */
        /* line-height: 1.5; */
        line-height: 200%;
    }

    span {
        font-size: 14px;
    }
</style>

<body>
    <div>
        <p>
            <span>项目部王广为</span>
        </p>
    </div>
</body>

</html>