zoukankan      html  css  js  c++  java
  • CSS中的::after ::before

    利用::after和before来清除浮动

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>利用::after和before来清除浮动</title>
        <style>
            #box::after,#box::before{
                content:"";
                height:0;
                visibility:hidden;
                display:block;
                clear:both;
            }
            h1{
                width:300px;
                height:300px;
                background-color:#ccc;
                float:left;
            }
            p{
                width:300px;
                height:300px;
                background-color:#f1f1f1;
            }
        </style>
    </head>
    <body>
        <div id="box">
            <h1>使用clear清除浮动问题</h1>
        </div>
        <p>我是p标签</p>
    </body>
    </html>

    利用::after或::before玩弄Css计数器

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
            ul{
                list-style:none;
                /* 初始化CSS计数器 并指定一个名称 我这里指定为count */
                counter-reset:count;
            }
            ul>li{
                /* 让 计数器每次自增 */
                counter-increment:count;
            }
            ul>li::before{
                /* 在页面输出 */
                content:counter(count);
                padding-right:20px;
            }
        </style>
    </head>
    <body>
        <ul>
            <li>li_1</li>
            <li>li_2</li>
            <li>li_3</li>
            <li>li_4</li>
            <li>li_5</li>
            <li>li_6</li>
        </ul>
    </body>
    </html>

    页面输出效果

    1   li_1
    2   li_2
    3 li_3
    4 li_4
    5   li_5
    6   li_6

     

  • 相关阅读:
    & 微信支付对比
    # MySQL性能优化技巧
    & mysql简单定时增量全量备份
    & Mysql高级总结
    python面向对象
    django虚拟环境的安装
    Python 内置函数
    Python列表解析式
    函数练习
    Python装饰器
  • 原文地址:https://www.cnblogs.com/pssp/p/5367651.html
Copyright © 2011-2022 走看看