日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

html css 多选下拉框,jQuery多选下拉框插件

發布時間:2025/3/20 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html css 多选下拉框,jQuery多选下拉框插件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

jquery.multi-select.js是一款jQuery多選下拉框插件。該插件可以將select元素轉換為帶checkbox的多選下拉框,非常實用。

使用方法

在頁面中引入下面的文件。

lt;link rel="stylesheet" type="text/css" href="./src/example-styles.css"gt;

lt;script src="js/jquery.min.js" type="text/javascript"gt;lt;/scriptgt;

lt;script type="text/javascript" src="./src/jquery.multi-select.js"gt;lt;/scriptgt;

HTML結構

lt;select id="languages" name="languages" multiplegt;

lt;option value="JavaScript"gt;JavaScriptlt;/optiongt;

lt;option value="C++"gt;C++lt;/optiongt;

lt;option value="Python"gt;Pythonlt;/optiongt;

lt;option value="Ruby"gt;Rubylt;/optiongt;

lt;option value="PHP"gt;PHPlt;/optiongt;

lt;option value="Pascal"gt;Pascallt;/optiongt;

lt;/selectgt;

初始化插件

$('#languages').multiSelect();

CSS樣式

.multi-select-container {

display: inline-block;

position: relative;

}

.multi-select-menu {

position: absolute;

left: 0;

top: 0.8em;

float: left;

min-width: 100%;

background: #fff;

margin: 1em 0;

padding: 0.4em 0;

border: 1px solid #aaa;

box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);

display: none;

}

.multi-select-menu input {

margin-right: 0.3em;

vertical-align: 0.1em;

}

.multi-select-button {

display: inline-block;

font-size: 0.875em;

padding: 0.2em 0.6em;

max-width: 20em;

white-space: nowrap;

overflow: hidden;

text-overflow: ellipsis;

vertical-align: -0.5em;

background-color: #fff;

border: 1px solid #aaa;

border-radius: 4px;

box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);

cursor: default;

}

.multi-select-button:after {

content: "";

display: inline-block;

width: 0;

height: 0;

border-style: solid;

border-width: 0.4em 0.4em 0 0.4em;

border-color: #999 transparent transparent transparent;

margin-left: 0.4em;

vertical-align: 0.1em;

}

.multi-select-container--open .multi-select-menu { display: block; }

.multi-select-container--open .multi-select-button:after {

border-width: 0 0.4em 0.4em 0.4em;

border-color: transparent transparent #999 transparent;

}

配置參數

$('#languages').multiSelect({

// 自定義HTML模板

'containerHTML': 'lt;div class="multi-select-container"gt;',

'menuHTML': 'lt;div class="multi-select-menu"gt;',

'buttonHTML': 'lt;span class="multi-select-button"gt;',

'menuItemsHTML': 'lt;div class="multi-select-menuitems"gt;',

'menuItemHTML': 'lt;label class="multi-select-menuitem"gt;',

'presetsHTML': 'lt;div class="multi-select-presets"gt;',

// sets some HTML (eg: lt;div class="multi-select-modal"gt;) to enable the modal overlay.

'modalHTML': undefined,

// Active CSS class

'activeClass': 'multi-select-container--open',

// Text to show when no option is selected

'noneText': '-- Select --',

// Text to show when all options are selected

'allText': undefined,

// an array of preset option groups

'presets': undefined,

// CSS class added to the container, when the menu is about to extend beyond the right edge of the position Menu Within element

'positionedMenuClass': 'multi-select-container--positioned',

// If you provide a jQuery object here, the plugin will add a class (see positionedMenuClass option) to the container when the right edge of the dropdown menu is about to extend outside the specified element, giving you the opportunity to use CSS to prevent the menu extending, for example, by allowing the option labels to wrap onto multiple lines.

'positionMenuWithin': undefined,

// The plugin will attempt to keep this distance, in pixels, clear between the bottom of the menu and the bottom of the viewport, by setting a fixed height style if the menu would otherwise approach this distance from the bottom edge of the viewport.

'viewportBottomGutter': 20,

// minimal height

'menuMinHeight': 200

});

《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的html css 多选下拉框,jQuery多选下拉框插件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。