lu2
Version:
Simple and flexible UI component library based on native HTML and JavaScript
282 lines (241 loc) • 5.53 kB
CSS
/**
*
* @Select.css
* @author zhangxinxu(.com)
* @create 15-06-18
* @edited 19-08-27
*
**/
select {
display: inline-block;
height: 40px;
margin: 0;
border: 1px solid #d0d0d5;
/* OS X padding-right无效 */
border-right: 27px solid #d0d0d5;
opacity: 0.0001;
font-size: 14px;
font-family: simsun;
vertical-align: middle;
}
select[width="100%"] {
width: 100%;
}
select[multiple] {
height: auto;
font-size: 38px;
font-size: calc(34px - 1px);
font-family: simsun;
padding: 0;
border-right-width: 1px;
vertical-align: top;
cursor: pointer;
}
select[multiple] > option {
min-height: 38px;
height: 38px;
padding: 0;
font-size: inherit;
}
select[multiple] > option:disabled {
cursor: default;
}
select[hidden],
select[hidden] + .ui-select {
display: none;
}
select[opacity="1"],
select[opacity="100%"],
select[style*="opacity:1"],
select[style*="opacity: 1"],
select[is-visible] {
opacity: 1;
border-right-width: 1px;
}
.ui-select {
display: inline-block;
height: 40px;
line-height: 20px;
vertical-align: middle;
font-size: 14px;
transition: opacity .2s;
text-align: left;
position: relative;
}
[multiple] ~ .ui-select {
vertical-align: top;
}
.ui-select.active {
z-index: 3;
}
.ui-select-button {
display: block;
height: 20px;
padding: 9px 27px 9px 12px;
color: #4c5161;
border: 1px solid #d0d0d5;
border-radius: 4px;
background-color: #fff;
text-decoration: none;
transition: border-color .15s, background-color .15s;
cursor: pointer;
}
.ui-select-button:hover {
color: #4c5161;
border-color: #ababaf;
}
:not(:disabled) + .ui-select > .ui-select-button:active {
background-color: #f7f9fa;
}
.active > a.ui-select-button {
border-color: #2a80eb;
border-radius: 4px 4px 0 0;
}
.reverse > a.ui-select-button {
border-radius: 0 0 4px 4px;
}
.ui-select-text {
display: block;
width: 100%;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
.ui-select-icon,
.ui-select-text:only-child::after {
position: absolute;
width: 20px;
height: 20px;
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cpath fill='%232a80eb' d='M145.659 68.949a12.874 12.874 0 0 0-18.473 0L99.479 97.233 71.772 68.949a12.874 12.874 0 0 0-18.473 0c-5.099 5.208-5.099 13.648 0 18.857l46.18 47.14 46.181-47.14c5.099-5.208 5.099-13.649-.001-18.857z'/%3E%3C/svg%3E") no-repeat center;
background-size: 20px 20px;
right: 7px;
top: 10px;
}
.ui-select-text:only-child::after {
content: '';
}
.ui-select-datalist {
position: absolute;
left: 0;
right: 0;
top: 39px;
display: none;
box-sizing: border-box;
max-height: 306px;
padding: 0;
border: 1px solid #2a80eb;
background-color: #fff;
overflow: auto;
overscroll-behavior: none;
-ms-scroll-chaining: none;
}
[multiple] ~ .ui-select > .ui-select-datalist {
position: static;
display: block;
max-height: none;
height: inherit;
border-color: #d0d0d5;
border-radius: 4px;
box-sizing: border-box;
}
[multiple]:hover ~ .ui-select > .ui-select-datalist {
border-color: #ababaf;
}
[multiple]:focus ~ .ui-select > .ui-select-datalist {
border-color: #2a80eb;
}
.ui-select-datalist::-webkit-scrollbar {
width: 8px;
height: 8px;
}
.ui-select-datalist::-webkit-scrollbar-thumb {
background-color: #bbb;
border-radius: 8px;
}
.ui-select-datalist::-webkit-scrollbar-thumb:hover {
background-color: #aaa;
}
.ui-select-datalist::-webkit-scrollbar-track-piece {
background-color: #ddd;
}
.active > .ui-select-datalist,
.ui-select-datalist.active {
display: block;
}
.reverse > .ui-select-datalist {
top: auto;
bottom: 39px;
}
.ui-select-intent {
text-indent: 1em;
}
.ui-select-datalist-li {
display: block;
line-height: 20px;
padding: 9px 12px;
color: #4c5161;
background-color: #fff;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
transition: background-color .15s;
overflow: hidden;
}
.ui-select-datalist-li[role="heading"] {
font-weight: 700;
margin: 0;
padding-bottom: 6px;
}
.ui-select-datalist-li[href] {
cursor: pointer;
}
.ui-select-datalist-li:not(:only-child):empty {
display: none;
}
.ui-select-datalist-hr:not(:first-child) {
border: 0;
border-bottom: 1px solid #d0d0d5;
margin: 7px 12px;
opacity: .38;
}
/* reset default a:hover */
.ui-select-datalist-li:hover {
color: #4c5161;
}
.ui-select-datalist > .disabled {
color: #a2a9b6;
cursor: default;
}
.ui-select-datalist > .selected {
background-color: #e0f0ff;
}
.ui-select-datalist-li[href]:hover,
[multiple] ~ .ui-select .ui-select-datalist-li[href] {
color: #4c5161;
background-color: #f0f7ff;
}
/* disabled */
select:disabled {
cursor: default;
}
select:disabled + .ui-select {
opacity: .38;
}
select:disabled + .ui-select .ui-select-button,
select:disabled + .ui-select .ui-select-datalist {
cursor: default;
border-color: #ababaf;
}
/* error */
.error .ui-select-button,
.error[multiple] ~ .ui-select .ui-select-datalist,
select.error {
border-color: #eb4646;
}
@media (prefers-reduced-motion: reduce) {
.ui-select,
.ui-select-button,
.ui-select-datalist-li {
transition: none;
}
}