【问题标题】:What is a good technique for poll result bars?什么是投票结果栏的好技术?
【发布时间】:2011-07-14 15:55:58
【问题描述】:

我正在创建一些投票软件,目前正在研究制作投票结果图表条的技术。没什么复杂的,只是一些简单的结果栏。

我想知道是否有任何经过验证的最佳方法。我想到的最好的方法是为每个条设置一个 div 容器,然后是一个图像或其他一些元素,您将大小(宽度)设置为等于选项结果百分比(内联 css)。

这个例子

强文本

// Option 1 Results
<div>
   <span style="background-color: #ff0000; width: 33%"></span>
</div>

// Option 2 Results
<div>
   <span style="background-color: #ff0000; width: 16%"></span>
</div>

等等……

任何人都知道任何更好的技术,或者这几乎是大多数人的做法?

【问题讨论】:

    标签: jquery asp.net html css


    【解决方案1】:

    是的,这是一个很好的方法。

    这是相同的想法,但更精细:

    Live Demo

    HTML:

    <div class="pollBars">
        <span class="t1" style="width: 10%">69</span>
        <span class="t1" style="width: 20%">100</span>
        <span class="t1" style="width: 70%">200</span>
        <span class="t2" style="width: 90%">666</span>
        <span class="t2" style="width: 120%">Over 9000!!</span>
    </div>
    

    CSS:

    .pollBars {
        width: 300px;
        background: #ccc
    }
    .pollBars span {
        display: block;
    
        padding: 3px;
        margin: 7px 0;
    
        font: bold 14px/1 sans-serif;
    
        -moz-border-radius: 4px;
        border-radius: 4px;
    
        text-shadow: 1px 1px 1px #444;
    }
    
    .t1 {
        color: #fff;
    
        border: 1px solid red;
    
        background: #f85032; /* old browsers */
        background: -moz-linear-gradient(top, #f85032 0%, #f16f5c 50%, #f6290c 51%, #f02f17 71%, #e73827 100%); /* firefox */
    
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f85032), color-stop(50%,#f16f5c), color-stop(51%,#f6290c), color-stop(71%,#f02f17), color-stop(100%,#e73827)); /* webkit */
    
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f85032', endColorstr='#e73827',GradientType=0 ); /* ie */
    }
    
    .t2 {
        color: #fff;
    
        border: 1px solid blue;
    
        background: #6db3f2; /* old browsers */
        background: -moz-linear-gradient(top, #6db3f2 0%, #54a3ee 50%, #3690f0 51%, #1e69de 100%); /* firefox */
    
        background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6db3f2), color-stop(50%,#54a3ee), color-stop(51%,#3690f0), color-stop(100%,#1e69de)); /* webkit */
    
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6db3f2', endColorstr='#1e69de',GradientType=0 ); /* ie */
    }
    

    【讨论】:

    猜你喜欢
    • 2012-02-02
    • 1970-01-01
    • 2011-10-08
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 2015-06-15
    • 2011-09-30
    相关资源
    最近更新 更多