繁体   English   中英

如何使用SelectBoxIt.js创建100%宽度选择

[英]How to create a 100% width select with SelectBoxIt.js

使用SelectBoxIt.js创建100%宽度选择框时遇到一些麻烦

即使将CSS宽度设置为100%,选择框也不会填充100%的容器元素。

CSS:

.test1, .test2, .test2 .selectboxit, .test2 .selectboxit-options {
  width: 100%;
}

HTML:

<select name="test2" class="test2">
  <option value="SelectBoxIt is:">SelectBoxIt is:</option>
  <option value="a jQuery Plugin">a jQuery Plugin</option>
  <option value="a Select Box Replacement">a Select Box Replacement</option>
  <option value="a Stateful UI Widget">a Stateful UI Widget</option>
</select>

JS

$(".mySelect").selectBoxIt({ autoWidth: false });

然后css

.selectboxit-container {
    width: 100%;
}

    .selectboxit-container .selectboxit {
    width: 100%;
}

Greg Franko帮助我解决了这个问题。

您可以在JSBin中看到解决方案。 http://jsbin.com/udapic/1/edit

基本上,你需要像这样禁用autoWidth:

$(".test2").selectBoxIt({ autoWidth: false, copyClasses: "container" });

然后在CSS中将宽度设置为100%:

.test1, .test2, .test2 .selectboxit, .test2 .selectboxit-options { width: 100%; }

暂无
暂无

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

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