我正在尝试更改显示所选选项的选择框的宽度,但是无论我如何尝试,都无法更改它,也无法更改框的颜色。
任何想法或建议都会受到赞赏。
我假设应该更改框的宽度的代码段如下(您可以看到我将其设置为25,但是宽度仍然很宽):
.selectpicker {
width: 25px;
您可以运行的代码段:
<script>
$(function() {
$('[data-toggle="tooltip"]').tooltip()
})
</script>
<script type = "text/javascript">
$(window).on('load', function() {
$('.selectpicker').selectpicker({
'selectedText': 'cat'
});
// $('.selectpicker').selectpicker('hide');
});
</script>
.text-muted {
font-size: small;
}
.text-bold {
font-weight: bold;
font-size: small;
}
.button {
background-color: #008CBA;
/* Light Blue */
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 11px;
margin: 4px 2px;
cursor: pointer;
border-radius: 4px;
padding: 6px 10px;
}
.button2 {
background-color: #008CBA;
/* Light Blue */
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 11px;
margin: 8px 2px;
cursor: pointer;
border-radius: 4px;
padding: 6px 10px;
}
.button2:hover {
background-color: #008CBA;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 30px 0 rgba(0, 0, 0, 0.19);
padding: 6px 10px;
}
/* Blue */
.button3 {
background-color: #f44336;
}
/* Red */
.button4 {
background-color: #e7e7e7;
color: black;
}
/* Gray */
.button5 {
background-color: #555555;
}
/* Black */
.button6 {
font-size: 12px;
padding: 8px 8px;
margin: 8px 0;
box-sizing: border-box;
border: none;
background-color: #D35324;
color: white;
padding: 6px 10px;
}
.button6:hover {
background-color: #037BA2;
color: white;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 30px 0 rgba(0, 0, 0, 0.19);
}
.button7 {
font-size: 12px;
padding: 8px 8px;
margin: 8px 0;
box-sizing: border-box;
border: none;
background-color: #008CBA;
color: white;
}
.button7:hover {
background-color: #008CBA;
color: white;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 30px 0 rgba(0, 0, 0, 0.19);
}
td {
text-align: left;
valign="middle";
}
i {
border: solid white;
border-width: 0 1px 1px 0;
display: inline-block;
padding: 2px;
}
.right {
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
}
.left {
transform: rotate(135deg);
-webkit-transform: rotate(135deg);
}
.up {
transform: rotate(-135deg);
-webkit-transform: rotate(-135deg);
}
.down {
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
.dropbtn {
background-color: #008CBA;
color: white;
padding: 12px;
font-size: 12px;
border: none;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 120px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown-content a {
color: #037BA2;
padding: 6px 6px;
text-align: center;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #037BA2;
color: white;
}
.dropdown:hover .dropdown-content {
display: block;
padding-top: 3px;
right: 0;
}
.dropdown:hover .dropbtn {
background-color: #037BA2;
}
input[id=Search],
select {
padding: 8px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[value=Apply] {
font-size: 12px;
padding: 8px 8px;
margin: 8px 0;
box-sizing: border-box;
border: none;
background-color: #D35324;
color: white;
}
input[value=Reset] {
font-size: 12px;
padding: 8px 8px;
margin: 8px 0;
box-sizing: border-box;
border: none;
background-color: #D35324;
color: white;
}
input[value=Apply]:hover {
background-color: #C44E22;
}
input[value=Reset]:hover {
background-color: #C44E22;
}
table.table1,
th.th1,
td.td1 {
width: 100%;
color: white;
font-size: 16px;
padding-left: 10px;
background-color: #008CBA;
}
.tooltip {
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 220px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: 150%;
left: 50%;
margin-left: -60px;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent black transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
.glyphicon.glyphicon-info-sign {
font-size: 25px;
top: 5px;
}
.selectpicker {
width: 25px;
height: 37px;
background-color: #008CBA !important;
border-style: solid;
border-left-width: 3px;
border-top: none;
border-bottom: none;
border-right: none;
color: black;
font-size: 14px;
font-weight: 200;
padding-left: 6px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
<head>
<!-- Bootstrap core CSS -->
<link href="dist/css/bootstrap.min.css" rel="stylesheet">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.bundle.min.js" integrity="sha384-pjaaA8dDz/5BgdFUPX6M/9SUZv4d12SUPF0axWc+VRZkx5xU3daN+lYb49+Ax+Tl" crossorigin="anonymous"></script>
<!-- JQUERY -->
<script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
<!-- BOOTSTRAP SELECT -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/js/bootstrap-select.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/css/bootstrap-select.css" />
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="dashboard.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="assets/js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<h3>START OF TESTING</h3>
<p><br><br></p>
<select class="selectpicker" data-style="btn-info" multiple data-max-options="4" data-actions-box="true">
<optgroup label="Select options below">
<option>Active</option>
<option>Inactive</option>
<option>Leave</option>
<option>No Status</option>
</optgroup>
</select>
<p><br><br></p>
<p><br><br></p>
<p><br><br></p>
<p><br><br></p>
<h3>END OF TESTING</h3>
<p><br><br></p>
<p><br><br></p>
<p><br><br></p>
<p><br><br></p>
<p><br><br></p>
</body>
答案 0 :(得分:1)
在选择选项中使用数据内容属性。 例如:
<select class="selectpicker form-control" data-live-search="true" id="subject_teacher_drop_down">
<option data-content="English">English</option>
<option data-content="Methodology of social...">Methodology of social science with special reference to economics</option>
</select>
答案 1 :(得分:0)
您所讨论的代码段示例根本不起作用。我做了一些清理工作,并在下面准备了另一个清理工作,还有JSFiddle。
.bootstrap-select {
width: 330px !important;
}
.btn-custom {
color: #fff;
background-color: #008CBA;
border-color: #008CBA;
}
您应该查看所有其他 btn-custom 颜色并进行相应调整。
<select class="selectpicker" data-style="btn-custom" multiple data-max-options="4" data-actions-box="true">
$(function() {
$('[data-toggle="tooltip"]').tooltip()
});
$('.selectpicker').selectpicker({
'selectedText': 'cat'
});
// $('.selectpicker').selectpicker('hide');
.text-muted {
font-size: small;
}
.text-bold {
font-weight: bold;
font-size: small;
}
.button {
background-color: #008CBA;
/* Light Blue */
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 11px;
margin: 4px 2px;
cursor: pointer;
border-radius: 4px;
padding: 6px 10px;
}
.button2 {
background-color: #008CBA;
/* Light Blue */
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 11px;
margin: 8px 2px;
cursor: pointer;
border-radius: 4px;
padding: 6px 10px;
}
.button2:hover {
background-color: #008CBA;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 30px 0 rgba(0, 0, 0, 0.19);
padding: 6px 10px;
}
/* Blue */
.button3 {
background-color: #f44336;
}
/* Red */
.button4 {
background-color: #e7e7e7;
color: black;
}
/* Gray */
.button5 {
background-color: #555555;
}
/* Black */
.button6 {
font-size: 12px;
padding: 8px 8px;
margin: 8px 0;
box-sizing: border-box;
border: none;
background-color: #D35324;
color: white;
padding: 6px 10px;
}
.button6:hover {
background-color: #037BA2;
color: white;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 30px 0 rgba(0, 0, 0, 0.19);
}
.button7 {
font-size: 12px;
padding: 8px 8px;
margin: 8px 0;
box-sizing: border-box;
border: none;
background-color: #008CBA;
color: white;
}
.button7:hover {
background-color: #008CBA;
color: white;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 30px 0 rgba(0, 0, 0, 0.19);
}
td {
text-align: left;
valign="middle";
}
i {
border: solid white;
border-width: 0 1px 1px 0;
display: inline-block;
padding: 2px;
}
.right {
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
}
.left {
transform: rotate(135deg);
-webkit-transform: rotate(135deg);
}
.up {
transform: rotate(-135deg);
-webkit-transform: rotate(-135deg);
}
.down {
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
.dropbtn {
background-color: #008CBA;
color: white;
padding: 12px;
font-size: 12px;
border: none;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 120px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown-content a {
color: #037BA2;
padding: 6px 6px;
text-align: center;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #037BA2;
color: white;
}
.dropdown:hover .dropdown-content {
display: block;
padding-top: 3px;
right: 0;
}
.dropdown:hover .dropbtn {
background-color: #037BA2;
}
input[id=Search],
select {
padding: 8px 20px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box;
}
input[value=Apply] {
font-size: 12px;
padding: 8px 8px;
margin: 8px 0;
box-sizing: border-box;
border: none;
background-color: #D35324;
color: white;
}
input[value=Reset] {
font-size: 12px;
padding: 8px 8px;
margin: 8px 0;
box-sizing: border-box;
border: none;
background-color: #D35324;
color: white;
}
input[value=Apply]:hover {
background-color: #C44E22;
}
input[value=Reset]:hover {
background-color: #C44E22;
}
table.table1,
th.th1,
td.td1 {
width: 100%;
color: white;
font-size: 16px;
padding-left: 10px;
background-color: #008CBA;
}
.tooltip {
display: inline-block;
border-bottom: 1px dotted black;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 220px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: 150%;
left: 50%;
margin-left: -60px;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
bottom: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent transparent black transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
}
.glyphicon.glyphicon-info-sign {
font-size: 25px;
top: 5px;
}
.selectpicker {
width: 25px;
height: 37px;
background-color: #008CBA !important;
border-style: solid;
border-left-width: 3px;
border-top: none;
border-bottom: none;
border-right: none;
color: black;
font-size: 14px;
font-weight: 200;
padding-left: 6px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.bootstrap-select {
width: 330px !important;
}
.btn-custom {
color: #fff;
background-color: #008CBA;
border-color: #008CBA;
}
.btn-custom:hover {
color: #fff;
background-color: #138496;
border-color: #117a8b;
}
.btn-custom:focus, .btn-custom.focus {
box-shadow: 0 0 0 0.2rem rgba(23, 162, 184, 0.5);
}
.btn-custom.disabled, .btn-custom:disabled {
color: #fff;
background-color: #17a2b8;
border-color: #17a2b8;
}
.btn-custom:not(:disabled):not(.disabled):active, .btn-custom:not(:disabled):not(.disabled).active,
.show > .btn-custom.dropdown-toggle {
color: #fff;
background-color: #117a8b;
border-color: #10707f;
}
.btn-custom:not(:disabled):not(.disabled):active:focus, .btn-custom:not(:disabled):not(.disabled).active:focus,
.show > .btn-custom.dropdown-toggle:focus {
box-shadow: 0 0 0 0.2rem rgba(23, 162, 184, 0.5);
}
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-custom,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-custom:hover,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-custom:focus,
.bootstrap-select > .dropdown-toggle.bs-placeholder.btn-custom:active {
color: rgba(255, 255, 255, 0.5);
}
<head>
<!-- JQUERY -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://unpkg.com/popper.js"></script>
<!-- Bootstrap core CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.min.js"></script>
<!-- BOOTSTRAP SELECT -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/css/bootstrap-select.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.1/js/bootstrap-select.min.js"></script>
</head>
<body>
<h3>START OF TESTING</h3>
<p><br><br></p>
<select class="selectpicker" data-style="btn-custom" multiple data-max-options="4" data-actions-box="true">
<optgroup label="Select options below">
<option>Active</option>
<option>Inactive</option>
<option>Leave</option>
<option>No Status</option>
</optgroup>
</select>
<p><br><br></p>
<p><br><br></p>
<p><br><br></p>
<p><br><br></p>
<h3>END OF TESTING</h3>
<p><br><br></p>
<p><br><br></p>
<p><br><br></p>
<p><br><br></p>
<p><br><br></p>
</body>