简体   繁体   English

如何将YUI 3 Slider小部件设置为100%宽度

[英]How to do YUI 3 Slider widget to be 100% width

Is there a way to set YUI 3 Slider widget to be 100% width ? 有没有办法将YUI 3 Slider widget设置为100% width
In the documentatiotn , length attribute is set in px . documentatiotn中length属性设置为px I tryed with % , but not work. 我尝试了% ,但没有用。

YUI().use('slider', function (Y) {
    var interval;
    var slider = new Y.Slider({
        min         : 0,
        max         : 3000,
        value       : 3000,
        length  : '100%'
    });
});

My site is responsive and my goal is to use only 1 slider in all media query break points. 我的网站反应灵敏,我的目标是在所有媒体查询断点中仅使用1个滑块。

If you change the slider length, the UI will be updated automatically . 如果您更改slider长度,则用户界面将自动更新

This means you can set the length at creation time and later change it if the window is resized: 这意味着您可以在创建时设置长度,然后在调整窗口大小时进行更改:

length  : Y.one('.slider-parent').getComputedStyle('width');

Add the event-resize module: 添加事件调整大小模块:

YUI().use('slider', 'event-resize' …

Resize logic: 调整大小逻辑:

Y.on('windowresize', function () { 
    slider.set('length', Y.one('.slider-parent').getComputedStyle('width'));
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM