ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

美化网站的实用 CSS3 技巧

2020-12-05 19:05:46  阅读:192  来源: 互联网

标签:CSS3 实用 rgba shadow 0px border 4px 美化 left


美化网站的实用 CSS3 技巧

黑白图像

.desaturate {
    filter: grayscale(100%);
    -webkit-filter: grayscale(100%);
    -moz-filter: grayscale(100%);
    -ms-filter: grayscale(100%);
    -o-filter: grayscale(100%);
}

在这里插入图片描述

页面顶部阴影

::before {
    content: "";
    position: fixed;
    top: -10px;
    left: 0;
    width: 100%;
    height: 10px;
    -webkit-box-shadow: 0px 0px 10px rgba(0, 0, 0, .8);
    -moz-box-shadow: 0px 0px 10px rgba(0, 0, 0, .8);
    box-shadow: 0px 0px 10px rgba(0, 0, 0, .8);
    z-index: 100;
}

CSS 实现三角形

.arrow-up {
    width: 0px;
    height: 0px;
    border-left: 5px solid transparent;
    /* left arrow slant */
    border-right: 5px solid transparent;
    /* right arrow slant */
    border-bottom: 5px solid #2f2f2f;
    /* bottom, add background color here */
    font-size: 0px;
    line-height: 0px;
}

/* create an arrow that points down */
.arrow-down {
    width: 0px;
    height: 0px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #2f2f2f;
    font-size: 0px;
    line-height: 0px;
}

/* create an arrow that points left */
.arrow-left {
    width: 0px;
    height: 0px;
    border-bottom: 5px solid transparent;
    /* left arrow slant */
    border-top: 5px solid transparent;
    /* right arrow slant */
    border-right: 5px solid #2f2f2f;
    /* bottom, add background color here */
    font-size: 0px;
    line-height: 0px;
}

/* create an arrow that points right */
.arrow-right {
    width: 0px;
    height: 0px;
    border-bottom: 5px solid transparent;
    /* left arrow slant */
    border-top: 5px solid transparent;
    /* right arrow slant */
    border-left: 5px solid #2f2f2f;
    /* bottom, add background color here */
    font-size: 0px;
    line-height: 0px;
}

在这里插入图片描述

文字渐变

h1[data-text] {
    position: relative;
    color: #f51010;
}

h1[data-text]::after {
    content: attr(data-text);
    z-index: 10;
    color: #f9fd04;
    position: absolute;
    top: 0;
    left: 0;
    -webkit-mask-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0)), color-stop(50%, rgba(0, 0, 0, 1)), to(rgba(0, 0, 0, 0)));
}

在这里插入图片描述

盒子虚线边框效果

.box {
    padding: 5px 10px;
    margin: 10px;
    background: #ff0030;
    color: #fff;
    font-size: 21px;
    line-height: 1.3em;
    border: 2px dashed #fff;
    border-radius: 3px;
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    -moz-box-shadow: 0 0 0 4px #ff0030, 2px 1px 4px 4px rgba(10, 10, 0, .5);
    -webkit-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);
    text-shadow: -1px -1px #aa3030;
}

.bg-yellow {		/**黄色**/
    background: #eccc30;
    box-shadow: 0 0 0 4px #eccc30, 2px 1px 6px 4px rgba(10, 10, 0, .5);
    -moz-box-shadow: 0 0 0 4px #eccc30, 2px 1px 4px 4px rgba(10, 10, 0, .5);
    -webkit-box-shadow: 0 0 0 4px #eccc30, 2px 1px 4px 4px rgba(10, 10, 0, .5);
}

在这里插入图片描述

模糊文本

.blur {
    color: rgba(0, 0, 0, 0);
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

在这里插入图片描述

右上角标签

.wrapper {
    margin: 50px auto;
    width: 280px;
    height: 370px;
    background: white;
    border-radius: 10px;
    -webkit-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
    -moz-box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
    box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 90;
}

.ribbon-wrapper-green {
    width: 85px;
    height: 88px;
    overflow: hidden;
    position: absolute;
    top: -3px;
    right: -3px;
}

.ribbon-green {
    font: bold 15px Sans-Serif;
    color: #333;
    text-align: center;
    text-shadow: rgba(255, 255, 255, 0.5) 0px 1px 0px;
    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    -o-transform: rotate(45deg);
    position: relative;
    padding: 7px 0;
    left: -5px;
    top: 15px;
    width: 120px;
    background-color: #BFDC7A;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A), to(#8EBF45));
    background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45);
    background-image: -moz-linear-gradient(top, #BFDC7A, #8EBF45);
    background-image: -ms-linear-gradient(top, #BFDC7A, #8EBF45);
    background-image: -o-linear-gradient(top, #BFDC7A, #8EBF45);
    color: #6a6340;
    -webkit-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.3);
    -moz-box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.3);
    box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.3);
}

.ribbon-green:before,
.ribbon-green:after {
    content: "";
    border-top: 3px solid #6e8900;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    position: absolute;
    bottom: -3px;
}

.ribbon-green:before {
    left: 0;
}

.ribbon-green:after {
    right: 0;
}
<div class="wrapper">
    <div class="ribbon-wrapper-green">
        <div class="ribbon-green">推荐</div>
    </div>
</div>

在这里插入图片描述

标签:CSS3,实用,rgba,shadow,0px,border,4px,美化,left
来源: https://blog.csdn.net/kDevelop/article/details/110709534

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有