2013-04-28 90 views
2

我已经修改了Slider UIjqueryUI,现在看起来是这样的: http://jsfiddle.net/eBukn/90/如何添加点以标记此滑块控件的每个步骤?

.ui-slider-handle{ 
    -webkit-border-radius: 50%; 
    color: #ecf0f1 !important; 
    line-height: 40px !important; 
    top: -15px !important; 
    width: 40px !important; 
    height: 40px !important; 
    background:#16a085 !important; 
    text-decoration: none; 
    text-align: center; 
    text-transform: uppercase; 
    border: none !important; 
    -webkit-transition:background .25s ease-in; 
    -moz-transition:background .25s ease-in; 
    -o-transition:background .25s ease-in; 
    transition:background .25s ease-in; 
    -webkit-backface-visibility: hidden !important; 
    cursor: pointer!important; 
} 

.ui-slider-handle:hover{ 
    background:#2fe2bf !important; 
} 

.ui-slider-handle:active{ 
    background:#16a085 !important; 
} 

.ui-slider-handle:focus{ 
    outline: none !important; 
} 

.ui-slider-range { 
    background:#1abc9c !important; 
    border: none !important; 
    -webkit-border-radius: 10px !important; 
} 

.ui-slider{ 
    -webkit-border-radius: 10px !important; 
    border: none !important; 
    background:#e8edf2 !important; 
} 

忘记的CSS,我做了一个快速的定制,也许它有一些错误......不管怎么说,我想要做的是在每个步骤中放入黑点,以便用户能够看到下一步的位置和数量。像在图像波纹管。

Here is a simulation

什么是做到这一点的最好方法是什么? 首先,我想把元素与jquery重复n次(取消步骤数)。但可能是纯CSS的可能。

你有什么想法或建议吗?

+1

广告为每个步骤定制一个span/div(并且定制它的样式)似乎是最简单的解决方案。你可以做到吗? – Uby 2013-04-28 16:11:35

+0

我试过了,但是恐怕我不能把它们放在比例的地方...... – harrison4 2013-04-28 16:16:00

+0

如果你把所有的span元素都放到一个div中,那么'display:inline-block'加'margin-right'应该可以工作。当然,你需要把父div放在一个连贯的方式 – Uby 2013-04-28 16:24:29

回答

3

可以吗?

http://jsfiddle.net/coma/V32MD/1/

CSS

.dots{ 
    width: 10px; 
    height: 10px; 
    background: black; 
    border-radius: 5px; 
    display: block; 
    position: absolute; 
    top: 2px; 
} 

JS

var foo = total - 1; 
var mar = $(".ui-slider").width()/foo; 

for (var x = 0; x < foo; x++){ 

    $(".ui-slider").append("<span class='dots' style='left:"+ x * mar + "px'></span>"); 
} 

你可以用百分比的EM太:http://jsfiddle.net/coma/V32MD/2/

+0

它是完美的!非常感谢@coma!很棒! – harrison4 2013-04-28 17:58:37

+1

哦!不用谢!。顺便说一下,它可以使用图像repeat-x(具有正确的空间),或者甚至使用类似http://lea.verou.me/css3patterns的非常CSS3流血边缘的方式来完成 – coma 2013-04-28 18:02:53

+0

好的,我注意到了。 ;)由此,这个sliderui不工作在我的手机,任何解决方案? – harrison4 2013-04-28 18:13:38