CSS3知识汇总14

【半透明边框】

body{background-color:green}

img{

    border:10px solid hsla(0, 0%, 100%, .5);

    background: white;

    background-clip: padding-box;

}

如果不希望背景侵入边框所在的范围,用padding-box将内边距的外沿把背景裁掉

【实线多重边框】

div{

    width:100px;

    height: 100px;

    margin:80px auto;

    background: yellowgreen;

    box-shadow: 0 0 0 10px #655,

                0 0 0 15px deeppink,

                0 2px 5px 15px rgba(0,0,0,.6);  /*投影*/

}

2.使用outline

div{

    width:100px;

    height: 100px;

    margin:80px auto;

    background: yellowgreen;

    border:10px solid #655;

    outline: 5px solid deeppink; /*适用双重边框*/

}

【虚线双重边框】

div{

    width:100px;

    height: 100px;

    margin:80px auto;

    background: yellowgreen;

    border:10px solid #655;

    outline: 5px dotted deeppink;

}

【背景定位】

div{

    background:url("css3.png") no-repeat bottom right #58a;

    background-position: right 20px bottom 10px;

    width: 600px;

    height: 600px;

}

【边框内圆角】

两个div时:

.con{

    background-color: #655;

    padding: .8em;

}

.con > div{

    background-color: tan;

    border-radius: .8em;

    padding:1em;

}

一个div时:

.con{

    background-color: tan;

    border-radius: .8em;

    padding: 1em;

    box-shadow: 0 0 0 .6em #655;

    outline: .6em solid #655;

    /*box-shadow: 0 0 0 .6em red;

    outline: .6em solid #000;  注释中的改变能看出如何实现的*/

}

【条纹背景】

.con{

    width: 300px;

    height: 200px;

}

1.颜色从#fb3过渡到#58a

background:linear-gradient(#fb3, #58a);

2.色标拉近一点

background:linear-gradient(#fb3 20%, #58a 80%);

3、变为50%,变成两色背景

background:linear-gradient(#fb3 50%, #58a 50%);

4、等宽条纹

background-size: 100% 30px;

background-size后,条纹变成等宽的15px

5、不等宽的条纹

background:linear-gradient(#fb3 20%, #58a 0%);

第二个色值值为0,它的位置就总是被浏览器调整为前一个色值的位置值

6、三色条纹

background:

        linear-gradient(to right,

        blue 33.3%, white 0,

        white 66.6%, red 0);

    background-size: 100% 30px;

7、四色条纹

background:

        linear-gradient(

            #fb3 33.3%, #58a 0,

            #58a 66.6%, yellowgreen 0,

            yellowgreen 88.8%, red 0

        );

8、垂直条纹

background:

        linear-gradient(to right,

            #fb3 50%, #58a 0

        );

to bottom是默认值

9、波纹条纹

background:

        linear-gradient(45deg,

            #fb3 50%, #58a 0

        );

10、斜向条纹

background:

        linear-gradient(45deg,

            #fb3 25%, #58a 0, #58a 50%,

            #fb3 0, #fb3 75%, #58a 0

        );

    background-size: 42px 42px; 

使用 repeating-linear-gradient循环

background:

        repeating-linear-gradient(45deg,

            #fb3, #fb3 15px, #58a 0, #58a 30px

        );

    background-size: 42px 42px;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 【渐变】 线性渐变:从一个位置开始向某个特定的方向渐变,如叶片 径向渐变:从一个位置开始向四周渐变,如灯光散落 l...
    0清婉0阅读 120评论 0 1
  • 今晚有个小激动,放下学习后,意外的得到了一笔小回报,虽然钱不多,但很开心。11月学习一小本英文书时发现一个错误,一...
    0清婉0阅读 216评论 0 1
  • 这篇文字里我会介绍50 个便于使用的 CSS2/CSS3 代码片段给所有的WEB专业人员. 选择IDE开发环境来存...
    JamHsiao_aaa4阅读 1,489评论 0 3
  • 多重变换,当一次应用多种变换效果时,将按照从左到右的顺序依次应用每个效果,各种转换函数之间用空格间隔 变换次序不能...
    0清婉0阅读 293评论 0 1
  • 今天感恩节哎,感谢一直在我身边的亲朋好友。感恩相遇!感恩不离不弃。 中午开了第一次的党会,身份的转变要...
    余生动听阅读 10,751评论 0 11

友情链接更多精彩内容