zoukankan      html  css  js  c++  java
  • 你可能用得到的9段CSS代码

    一、opacity兼容

    .transparent {
        filter: alpha(opacity=50);/* internet explorer */
        -khtml-opacity: 0.5;     /* khtml, old safari */
        -moz-opacity: 0.5;      /* mozilla, netscape */
        opacity: 0.5;          /* fx, safari, opera */
    }


    二、个性化圆角

     #container {
        -webkit-border-top-left-radius: 4px;
        -webkit-border-top-rightright-radius: 3px;
        -webkit-border-bottom-rightright-radius: 6px;
        -webkit-border-bottom-left-radius: 10px;
        -moz-border-radius-topleft: 4px;
        -moz-border-radius-topright: 3px;
        -moz-border-radius-bottomright: 6px;
        -moz-border-radius-bottomleft: 10px;
    }

    三、隐藏Logo上的H1文本
       
    h1 {
        text-indent: -9999px;
        margin: 0 auto;
        320px;
        height: 85px;
        background: transparent url("images/logo.png") no-repeat scroll;
    }

    四、为图片创建拍立得效果边框
       
    img.polaroid {
        background:#000;
        border:solid #fff;
        border-6px 6px 20px 6px;
        box-shadow:1px 1px 5px #333;
        -webkit-box-shadow:1px 1px 5px #333;
        -moz-box-shadow:1px 1px 5px #333;
        height:200px;
        200px;
    }

    五、全屏背景固定效果

       
    html {
        background: url('images/bg.jpg') no-repeat center center fixed;
        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
        background-size: cover;
    }


    六、内容垂直集中

    .container {
        min-height: 6.5em;
        display: table-cell;
        vertical-align: middle;
    }

    七、创建缝合效果

    p {
        position:relative;
        z-index:1;
        padding: 10px;
        margin: 10px;
        font-size: 21px;
        line-height: 1.3em;
        color: #fff;
        background: #ff0030;
        -webkit-box-shadow: 0 0 0 4px #ff0030, 2px 1px 4px 4px rgba

    (10,10,0,.5);
        -moz-box-shadow: 0 0 0 4px #ff0030, 2px 1px 4px 4px rgba(10,10,0,.5);
        box-shadow: 0 0 0 4px #ff0030, 2px 1px 6px 4px rgba(10,10,0,.5);
        -webkit-border-radius: 3px;
        -moz-border-radius: 3px;
        border-radius: 3px;
    }
    p:before {
        content: "";
        position: absolute;
        z-index: -1;
        top: 3px;
        bottombottom: 3px;
        left :3px;
        rightright: 3px;
        border: 2px dashed #fff;
    }  
    p a {
        color: #fff;
        text-decoration:none;
    }
    p a:hover, p a:focus, p a:active {
        text-decoration:underline;
    }

    八、经典的CSS Clearfix

    .clearfix:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; }
    .clearfix { display: inline-block; }
    html[xmlns] .clearfix { display: block; }
    * html .clearfix { height: 1%; }

    九、垂直滚动条

    这段代码将确保你的HTML元素总是稍微高于浏览器滚动条所停留的位置。
    html { height: 101% }

     
  • 相关阅读:
    Dom对象和jQuery对象区别 jQuery对象转换为Dom对象、、Dom对象转换为jquery对象
    jquery 1,2,3三个版本的下载、区别/以及jquery使用步骤,jQuery入口函数
    2021年3月4日 第一周开课博客
    2021年3月3日
    2021年3月2日
    2021年2月24日 记账本开发07
    2021年2月23日 记账本开发06
    2021年2月22日 记账本开发05
    程序员修炼之道读书笔记03
    2021年2月21日 记账本开发04
  • 原文地址:https://www.cnblogs.com/wqsbk/p/3493953.html
Copyright © 2011-2022 走看看