zoukankan      html  css  js  c++  java
  • [置顶] css3 befor after 简单使用 制作时尚焦点图相框

    :befor、:after是CSS的伪元素,什么是伪元素呢?伪元素用于向某些选择器设置特殊效果。

    我们用CSS手册可以查询到其基本的用法:

    • E:before/E::before 设置在对象前(依据对象树的逻辑结构)发生的内容。用来和content属性一起使用
    • E:after/E::after 设置在对象后(依据对象树的逻辑结构)发生的内容。用来和content属性一起使用
    • Ie6-7 不支持 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
        <title>css_brfor_after</title>
        <style type="text/css">
            body {
                 300px;
                height: auto;
                display: block;
                margin: 0px auto;
                padding: 0px;
                text-align: left;
                text-decoration: none;
                background: #efeeea;
                background: linear-gradient(#f9f9f9, #cecbc4);
                background: -moz-linear-gradient(#f9f9f9, #cecbc4);
                background: -webkit-linear-gradient(#f9f9f9, #cecbc4);
                background: -o-linear-gradient(#f9f9f9, #cecbc4);
            }
    
            #box {
                 300px;
                height: 300px;
            }
    
                #box .relative {
                     288px;
                    height: 288px;
                    margin-left: 5px;
                    margin-top: 5px;
                    background-color: transparent;
                    border-radius: 5px;
                    -moz-border-radius: 5px;
                    border: 2px solid red;
                    position: absolute;
                }
    
                    #box .relative:before {
                         288px;
                        height: 248px;
                        background-color: transparent;
                        border-left: 2px solid #fff;
                        border-right: 2px solid #fff;
                        position: absolute;
                        content: '';
                        left: -2px;
                        top: 20px;
                    }
    
                    #box .relative:after {
                         248px;
                        height: 288px;
                        background-color: transparent;
                        border-top: 2px solid #fff;
                        border-bottom: 2px solid #fff;
                        position: absolute;
                        content: '';
                        top: -2px;
                        left: 20px;
                    }
        </style>
    </head>
    
    <body>
        <div id="box">
            <div class="relative"></div>
            <img src="ba.png" width="300" height="300" alt="心" title="心" />
        </div>
    </body>
    </html>
    


  • 相关阅读:
    jquery两个滚动条样式
    js双层动画幻灯
    漂浮QQ
    js物理弹性窗口
    js抽奖跑马灯程序
    经典算法
    判断手机浏览器终端设备
    javascript判断手机旋转横屏竖屏
    【转】处理百万级以上的数据提高查询速度的方法
    Linux -- Centos 下配置LNAMP 服务器环境
  • 原文地址:https://www.cnblogs.com/james1207/p/3279962.html
Copyright © 2011-2022 走看看