html结构,只有一个span,不能增加html元素也不能增加id,class等任何属性。制作效果如下图 每个块 100X100px 颜色分别为 red, orange, yellow, green, blue, indigo

<span></span>

第一种方法:span 加两个伪元素 利用 分别写左边框和右边框一共六个色块

      span {
        position: relative;
        display: block;
        height: 100px;
        width: 0;
        border-left: 100px solid red;
        border-right: 100px solid orange;
      }
      span::before {
        content: "";
        height: 100px;
        display: block;
        border-left: 100px solid yellow;
        border-right: 100px solid green;
        margin-left: 100px;
      }
      span::after {
        position: absolute;
        top: 0;
        content: "";
        height: 100px;
        display: block;
        border-left: 100px solid blue;
        border-right: 100px solid indigo;
        margin-left: 300px;
      }

第二种方法:渐变写出六个色块

    span{display: block; width: 600px; height: 100px; background: linear-gradient(to right,  red 0%,red 16%,orange 16%,orange 33%,yellow 33%,yellow 33%,yellow 49%,green 49%,green 66%,blue 66%,blue 83%,indigo 83%,indigo 100%);}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。