为了账号安全,请及时绑定邮箱和手机立即绑定

纯css3如何实现宽高动态相等!

纯css3如何实现宽高动态相等!

暮色呼如 2018-08-25 18:13:25
除了用vw之外!!
查看完整描述

2 回答

?
一只斗牛犬

TA贡献1784条经验 获得超2个赞

<!DOCTYPE html>

<html>

    <head>

        <meta charset="UTF-8">

        <title></title>

        <style>

            *{

                margin: 0;

                padding: 0;

            }

            .box{

                width: 70%;  

                position:relative;                    

            }

            .box:before{

                content: '';

                padding-top: 100%;

                box-sizing: border-box;   

                display: block;

                width: 0;  

            }

            .pox{                

               position:absolute;

               height:100%;

               width:100%;

               left: 0;

               top: 0;         

               border: 1px solid red;

               box-sizing: border-box;

            }

        </style>

    </head>

    <body>

        <div class="box">

            <div class="pox">11111</div>

        </div>

    </body>

</html>


查看完整回答
反对 回复 2018-09-02
  • 2 回答
  • 0 关注
  • 3556 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信