1

在此处输入图像描述
jsFiddle 示例

我正在寻找最时髦的方法来减少 HTML 语义(css 可以根据需要很大)这个 4 色徽标不使用图片,任何结构都可以改变。唯一的要求是它可以在 IE8 中运行。我正在使用 selectivr 和 modernizr 所以大多数选择器类等应该可以工作。此外,我使用的 CSS 较少,所以如果你也可以这样写。

  <ul class="logo">
    <li class="webBG"></li>
    <li class="designBG"></li>
    <li class="videoBG"></li>
    <li class="audioBG"></li>
  </ul>

CSS

ul.logo{margin: 0 0 0 10px;padding: 0;list-style-type: none;}
ul.logo li{display: inline-block; width:5px;height:5px; padding:0;margin:0; float:left;}
.designBG{background:#00c8e8}
.videoBG{background:#33cc77}
.webBG{background:#ec8544}
.audioBG{background:#E58}

更新最终解决方案

#boilerplate > div{
margin-left:10px;

width:20px;
height:5px;

/*cross browser definitions follow..*/
background-image: -o-linear-gradient(left,
                        #ec8544 0%, #ec8544 25%,
                        #00c8e8 26%, #00c8e8 50%,
                        #33cc77 51%, #33cc77 75%,
                        #Ee5588 76%, #Ee5588 100%);
background-image: -moz-linear-gradient(left,
                        #ec8544 0%, #ec8544 25%,
                        #00c8e8 26%, #00c8e8 50%,
                        #33cc77 51%, #33cc77 75%,
                        #Ee5588 76%, #Ee5588 100%);
background-image: -webkit-linear-gradient(left,
                        #ec8544 0%, #ec8544 25%,
                        #00c8e8 26%, #00c8e8 50%,
                        #33cc77 51%, #33cc77 75%,
                        #Ee5588 76%, #Ee5588 100%);
background-image: -ms-linear-gradient(left,
                        #ec8544 0%, #ec8544 25%,
                        #00c8e8 26%, #00c8e8 50%,
                        #33cc77 51%, #33cc77 75%,
                        #Ee5588 76%, #Ee5588 100%);
background-image: linear-gradient(left,
                        #ec8544 0%, #ec8544 25%,
                        #00c8e8 26%, #00c8e8 50%,
                        #33cc77 51%, #33cc77 75%,
                        #Ee5588 76%, #Ee5588 100%);

}​</p>

HTML

<div></div>
4

3 回答 3

1

您可以使用背景线性渐变..

html

<div class="logo"></div>

css

.logo{
    margin-left:10px;

    width:20px;
    height:5px;

    /*cross browser definitions follow..*/
    background-image: -o-linear-gradient(left,
                            #ec8544 0%, #ec8544 25%,
                            #00c8e8 26%, #00c8e8 50%,
                            #33cc77 51%, #33cc77 75%,
                            #Ee5588 76%, #Ee5588 100%);
    background-image: -moz-linear-gradient(left,
                            #ec8544 0%, #ec8544 25%,
                            #00c8e8 26%, #00c8e8 50%,
                            #33cc77 51%, #33cc77 75%,
                            #Ee5588 76%, #Ee5588 100%);
    background-image: -webkit-linear-gradient(left,
                            #ec8544 0%, #ec8544 25%,
                            #00c8e8 26%, #00c8e8 50%,
                            #33cc77 51%, #33cc77 75%,
                            #Ee5588 76%, #Ee5588 100%);
    background-image: -ms-linear-gradient(left,
                            #ec8544 0%, #ec8544 25%,
                            #00c8e8 26%, #00c8e8 50%,
                            #33cc77 51%, #33cc77 75%,
                            #Ee5588 76%, #Ee5588 100%);
    background-image: linear-gradient(left,
                            #ec8544 0%, #ec8544 25%,
                            #00c8e8 26%, #00c8e8 50%,
                            #33cc77 51%, #33cc77 75%,
                            #Ee5588 76%, #Ee5588 100%);
}

演示在http://jsfiddle.net/gaby/yGkhQ/

于 2012-04-25T21:14:49.057 回答
1

最少的html:

http://jsfiddle.net/VRXjc/7/

  1. 创建 1 个 div

  2. 使用 CSS 渐变来制作颜色

  3. 将边距、高度和宽度设置为样式

HTML:

<div id="logo"></div>

CSS:

#logo{
background: #ec8544; /* Old browsers */
background: -moz-linear-gradient(left,  #ec8544 25%, #00c8e8 25%, #00c8e8 50%, #33cc77 50%, #33cc77 75%, #ee5588 75%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(25%,#ec8544), color-stop(25%,#00c8e8), color-stop(50%,#00c8e8), color-stop(50%,#33cc77), color-stop(75%,#33cc77), color-stop(75%,#ee5588)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left,  #ec8544 25%,#00c8e8 25%,#00c8e8 50%,#33cc77 50%,#33cc77 75%,#ee5588 75%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left,  #ec8544 25%,#00c8e8 25%,#00c8e8 50%,#33cc77 50%,#33cc77 75%,#ee5588 75%); /* Opera 11.10+ */
background: -ms-linear-gradient(left,  #ec8544 25%,#00c8e8 25%,#00c8e8 50%,#33cc77 50%,#33cc77 75%,#ee5588 75%); /* IE10+ */
background: linear-gradient(left,  #ec8544 25%,#00c8e8 25%,#00c8e8 50%,#33cc77 50%,#33cc77 75%,#ee5588 75%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ec8544', endColorstr='#ee5588',GradientType=1 ); /* IE6-9 */
margin: 0px 0px 0px 15px;
width:20px;
height:5px;
}
于 2012-04-25T21:17:28.720 回答
0

HTML:

  <div id="boilerplate">
      <ul>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
      </ul>
  </div>

CSS:

div#boilerplate{}
div#boilerplate ul{margin: 0 0 0 10px;padding: 0;list-style-type: none;}
div#boilerplate ul li{display: inline-block; width:5px;height:5px; padding:0;margin:0; float:left;}
div#boilerplate ul li:first-child {background:#00c8e8;}
div#boilerplate ul li:nth-child(2) {background:#33cc77;}
div#boilerplate ul li:nth-child(3) {background:#ec8544;}
div#boilerplate ul li:last-child {background:#E58;}
于 2012-04-25T21:10:26.790 回答