开发者

jquery sliders, widen click area?

开发者 https://www.devze.com 2023-01-15 06:13 出处:网络
I have some jquery ui sliders you can see here开发者_JAVA技巧 When you click the slider bar, the tic jumps to that part of the bar. This is great however the bar is very thin and easy to miss when yo

I have some jquery ui sliders you can see here

开发者_JAVA技巧

When you click the slider bar, the tic jumps to that part of the bar. This is great however the bar is very thin and easy to miss when you try to click it. I don't want to change the appearance but I am wondering if there is a way to make the click radius a little padded so if you click a few pixels above or below the bar it still counts as clicking the bar.


It's a pretty hackish solution, but I believe this will work. What you need to do is to inject an additional transparent element into each slider that has a height larger than it's parent's. The code looks something like this:

$('<div></div>').appendTo('.ui-slider').css({
    'height': '20px',
    'position': 'absolute',
    'top': '-8px',
    'width': '100%'
});

Of course it would be better if you give them a class and apply the CSS in the stylesheet instead. In addition to that, I would suggest adding in cursor: pointer to make it clear which areas are clickable.

0

精彩评论

暂无评论...
验证码 换一张
取 消