CSS背景色渐变(图例)

CSS背景色渐变(图例)

项目中需要做个渐变色图例,刚看到这个效果我是拒绝的,一张图片解决他不香吗?奈何强迫症犯了就用css写了,看效果图(主要难搞的是下面得半截白线)。
在这里插入图片描述

直接上代码
html
	<div class="legendPara">
        <div class="legendParabox">
            <ul class="clearfix">
                <li></li>
                <li></li>
                <li class="mr"></li>
            </ul>
            <p>
                <s>0</s>
                <s>0.3</s>
                <s>0.8</s>
                <s>2</s>
            </p>
        </div>
    </div>
css
	*{
		margin: 0;
		padding: 0;
	}
	li{
		list-style: none;
	}
	s{
		text-decoration: none;
	}
	.legendPara{
		width: 282px;
	    padding: 10px;
	    height: 43px;
	    display: flex;
	    align-items: center;
	    background: rgba(0,0,0,0.3);
	}

	.legendPara ul{
	    width: 278px;
	    height: 23px;
	    padding: 1px;
	    background: linear-gradient(top, transparent 80%, #fff 80%, #fff 100%);
	    background: -ms-linear-gradient(top, transparent 80%, #fff 80%, #fff 100%);
	    background: -webkit-linear-gradient(top, transparent 80%, #fff 80%, #fff 100%);
	    background: -moz-linear-gradient(top, transparent 80%, #fff 80%, #fff 100%);
	}
	.legendPara ul li{
	    float: left;
	    width: 92px;
	    height: 23px;
	    background: pink;
	    margin-right: 1px;
	    border: 1px solid #091220;
	    border-top: 1px solid #091220;
	    border-bottom: 1px solid #091220;
	    box-sizing: border-box;
	}
	.legendPara ul li:nth-child(1){
	    background: linear-gradient(left, #00D9E1, #00FF12);
	    background: -ms-linear-gradient(left, #00D9E1, #00FF12);
	    background: -webkit-linear-gradient(left, #00D9E1, #00FF12);
	    background: -moz-linear-gradient(left, #00D9E1, #00FF12);
	    border-left: 1px solid #091220;
	}
	.legendPara ul li:nth-child(2){
	    background: linear-gradient(left, #fefe23, #FF9600);
	    background: -ms-linear-gradient(left, #fefe23, #FF9600);
	    background: -webkit-linear-gradient(left, #fefe23, #FF9600);
	    background: -moz-linear-gradient(left, #fefe23, #FF9600 );
	}
	.legendPara ul li:nth-child(3){
	    background: linear-gradient(left, #ff1b1b, #950101);
	    background: -ms-linear-gradient(left, #ff1b1b, #950101);
	    background: -webkit-linear-gradient(left, #ff1b1b, #950101);
	    background: -moz-linear-gradient(left, #ff1b1b, #950101);
	    border-right: 1px solid #091220;
	    margin-right: 0;
	}
	.legendPara p{
	    display: block;
	}
	.legendPara p s{
	    font-size: 12px;
	    line-height: 16px;
	    margin-right: 72px ;
	}
	.legendPara p s:nth-last-child(1){
	    margin-right: 0;
	}	

番外篇:
没有营养的文章第二篇,万一一不小心对你有点启发,点个赞!谢谢了!~

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值