nouislider的自定义图像句柄 [英] custom image handle for nouislider

查看:84
本文介绍了nouislider的自定义图像句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站上使用noUislider效果很好.今天,我想到了将手柄从无聊的圆角矩形更改为图像的想法.我以为这是简单的CSS背景图像"添加,但是事实证明不可能显示我的图像.我在这里有人要显示图像吗?

I'm using noUislider with great effect on my website. Today I had the idea to change the handles from the boring rounded rectangles to images. I thought it would be a simple css 'background-image' addition, but it's proving to be impossible to get my images showing. I anyone here getting an image to show?

noUislider的作者在帖子 https://github.com/leongersen中建议了以下CSS/noUiSlider/issues/172 :

The author of noUislider suggested the following css in the post https://github.com/leongersen/noUiSlider/issues/172:

.noUi-handle {
  background-image: url('/path/to/your/image.png');
}

我已将其添加到jquery.nouislider.css文件中,但这不起作用.如果作者的编码不起作用,那就没有希望了.我目前有:

I had added this into the jquery.nouislider.css file however this doesn't work. if the authors coding doesn't work then there is little hope. I currently have:

.noUi-handle {
    border: 1px solid #cccccc;
    border-radius: 5px;
    background: #fff; /* For Safari 5.1 to 6.0 */
    cursor: col-resize;
    box-shadow: inset 0 0 1px #FFF,
                inset 0 1px 7px #EBEBEB,
                0 3px 6px -3px #BBB;
}

,当我将其更改为(用背景图像替换背景)时:

and when I change this to (replacing background with background-image):

.noUi-handle {
    border: 1px solid #cccccc;
    border-radius: 5px;
    background-image: url(images/handle.png);
    cursor: col-resize;
    box-shadow: inset 0 0 1px #FFF,
                inset 0 1px 7px #EBEBEB,
                0 3px 6px -3px #BBB;
}

手柄是透明的,没有图像.有人能帮我一下吗?如此愚蠢的问题!非常感谢.

the handle is transparent, no image. can anyone help me here? such a silly problem! Many thanks.

推荐答案

.noUi-handle {
    border: 1px solid #cccccc;
    border-radius: 5px;
    background-color: #fff; /* For Safari 5.1 to 6.0 */
    background-image: url(images/handle.png);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    cursor: col-resize;
    box-shadow: inset 0 0 1px #FFF,
                inset 0 1px 7px #EBEBEB,
                0 3px 6px -3px #BBB;
}

如果不起作用: use => !important

background-image: url(images/handle.png)!important;
background-size: 100% 100%!important;
background-repeat: no-repeat!important;

这篇关于nouislider的自定义图像句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆