zoukankan      html  css  js  c++  java
  • 使用纯css代码实现div的“回”字型“叠放”效果

    正如大家所知道的那样,div是一个块级元素,也是网页编写过程中使用频率最高的一个元素,通过不同的样式控制可以实现一些最常见的页面效果,当然也可以实现一些比较复杂的页面效果,这里就展示一个本人面试过程中遇到的一个问题,如何使用最简单css样式通过div实现“回”字型图样?父类div必须设置的属性是什么?当然实现方法很多很多,下面就和大家分享一下我自己的方法(兼容Trident,Gecko,Presto,WebKit等内核浏览器),先看效果:

    再看详细的代码:

    <html>
    <head>
    <title>Test</title>
    <style type="text/css">
    #bigcontent {
         400px;
        height: 400px;
        margin: 50px 0 0 50px;
        position: absolute;
        background: yellow;
        text-align: center;//这个是父类元素必须设置的样式,目的是让所有子元素都水平居中摆放
    }

    #precontent {
         350px;
        height: 350px;
        margin-top: 30px;
        display: inline-block;//这个是子元素必须设置的样式,否则其他浏览器不兼容
        background: blue;
    }

    #middlecontent {
         300px;
        height: 300px;
        background: red;
        margin-top: 25px;
        display: inline-block;
    }
    #premidcontent{
        250px;
        height: 250px;
        display: inline-block;
        background: lime;
        margin-top: 25px;
    }
    #smallcontent {
         200px;
        height: 200px;
        display: inline-block;
        background: green;
        margin-top: 25px;
    }
    #finalcontent{
       150px;
       height: 150px;
       display: inline-block;
       background:orange;
       margin-top: 25px;
       text-align: center;
    }
    </style>
    </head>
    <body>
        <div id="bigcontent">
            <div id="precontent">
                <div id="middlecontent">
                    <div id="premidcontent">
                        <div id="smallcontent">
                           <div id="finalcontent">
                           </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </body>
    </html>

  • 相关阅读:
    1130 host '***' is not allowed to connect to this MySQL server
    签名时出错,未能对....ext签名。SignTool Error: No certificates...
    C# 进制转换(二进制、十六进制、十进制互转)
    在安装32位Oracle客户端组建的情况下以64位模式运行
    Vue中引入jQuery
    sql server数据库分离时,数据库右侧显示(单个用户)
    解决Typora图片显示问题
    Ruby日文手册翻译1
    Boost Graph Library 库小结1
    归并排序
  • 原文地址:https://www.cnblogs.com/ljhoracle/p/4046325.html
Copyright © 2011-2022 走看看