继承父元素的浮动属性问题

来源:4-7 编程练习

水果大王

2020-05-26 22:00:44

在div3中,写入了继承父元素的浮动属性,float:inherit;  意思div3的父元素就是div2,对吗?然而在div1和div2中补充两行代码即可!

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>float</title>

    <style>

        .div1{

            width: 30px;

            height: 100px;

            background: red;

           float:left;

        }

        .div2{

            width: 90px;

            height: 300px;

            background: blue;

            float:right;

        }

        .div3{

            width: 30px;

            height: 100px;

            background: green;

           float:inherit;

        }

    </style>

</head>

<body>

    <div class="div1"></div>

    <div class="div2">

        <div class="div3"></div>

    </div>

</body>

</html>


写回答

1回答

好帮手慕觉浅

2020-05-27

同学你好:你的理解是正确的,添加两行代码即可。

如果解决了你的疑惑,请采纳,祝学习愉快~


0

0 学习 · 3562 问题

查看课程