不经历项目的苦,哪能体会一像素一边框一阴影带来的痛(为了减少痛苦,建议收藏备用)
。
/* select格式化样式: */
.select {
border: 1px solid #C6CBD4;
outline: none;
text-shadow: none;
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
-webkit-user-select: text;
box-shadow: none;
}
/* button格式化样式: */
#searchBtn {
width: 134px;
height: 40px;
font-weight: bold;
background-color: #0FB273;
cursor: pointer;
color: #fff;
outline: none;
border: none;
text-shadow: none;
-webkit-appearance: none;
-webkit-user-select: text;
box-shadow: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
/* input去除边框: */
input {
outline: none;
border: 0;
}
/* selection去除下拉三角按钮: */
select {
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
}
select::-ms-expand {
display: none;
}
/* textarea隐藏右下角拖动及滚动条: */
#refuseTextarea {
width: 680px;
height: 160px;
resize: none;
text-indent: 10px;
line-height: 20px;
border-radius: 4px;
padding: 5px 0;
border: none;
outline: none;
}
#refuseTextarea::placeholder {
color: rgba(0, 0, 0, 0.25);
}
#refuseTextarea::-webkit-scrollbar {
width: 0;
display: none;
}
/* textarea滚动条——针对firefox浏览器 */
textarea {
scrollbar-color: transparent transparent;
scrollbar-track-color: transparent;
-ms-scrollbar-track-color: transparent;
}
/* flex布局 */
.flexBox {
display: flex;
display: -moz-flex;
display: -o-flex;
display: -webkit-flex;
display: -ms-flex;
}
/* 不重复百分百背景图居中 */
.bgCover {
background-position: center;
background-repeat: no-repeat;
background-size: 100% 100%;
}
/* 文本两端对齐: */
.text {
text-align-last: justify;
text-align: justify;
text-justify: distribute-all-lines;
/* 兼容ie */
}
/* 文本不被选中(可禁止移动端长按选中复制): */
body {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* 防止滚动条导致页面晃动: */
html {
overflow-y: scroll;
}
:root {
overflow-x: auto;
overflow-y: hidden;
}
:root body {
position: absolute;
}
body {
width: 100vw;
overflow: hidden;
}
/* 按钮轮廓: */
.button {
box-shadow: inset -1px 0px 1px 1px #333;
}
/* table表格多行居中: */
.missionTable .limitCell {
line-height: 20px;
display: table-cell;
vertical-align: middle;
}
.textWrap {
/* 自动换行(包括网址): */
word-wrap: break-word;
word-break: break-all;
white-space: normal;
/* 单行文本溢出省略号: */
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* 复选框不同状态背景图: */
.checkList>input {
width: 16px;
height: 16px;
border-radius: 2px;
position: relative;
}
.checkList>input::after {
content: "";
width: 16px;
height: 16px;
position: absolute;
background-repeat: no-repeat;
background-size: 16px 16px;
background-position: center;
}
.checkList>input:checked::after {
background-image: url('../images/selected.png');
}
.checkList>input:disabled::after {
background-image: url('../images/choose.png');
}
<label><input class="mui-switch mui-switch-animbg" type="checkbox">文字label>
.mui-switch {
width: 52px;
height: 31px;
position: relative;
border: 1px solid #dfdfdf;
background-color: #fdfdfd;
box-shadow: #dfdfdf 0 0 0 0 inset;
border-radius: 20px;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
background-clip: content-box;
display: inline-block;
-webkit-appearance: none;
user-select: none;
outline: none;
}
.mui-switch:before {
content: '';
width: 29px;
height: 29px;
position: absolute;
top: 0px;
left: 0;
border-radius: 20px;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
background-color: #fff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.mui-switch:checked {
border-color: #64bd63;
box-shadow: #64bd63 0 0 0 16px inset;
background-color: #64bd63;
}
.mui-switch:checked:before {
left: 21px;
}
.mui-switch.mui-switch-animbg {
transition: background-color ease 0.4s;
}
.mui-switch.mui-switch-animbg:before {
transition: left 0.3s;
}
.mui-switch.mui-switch-animbg:checked {
box-shadow: #dfdfdf 0 0 0 0 inset;
background-color: #64bd63;
transition: border-color 0.4s, background-color ease 0.4s;
}
.mui-switch.mui-switch-animbg:checked:before {
transition: left 0.3s;
}
.mui-switch.mui-switch-anim {
transition: border cubic-bezier(0, 0, 0, 1) 0.4s, box-shadow cubic-bezier(0, 0, 0, 1) 0.4s;
}
.mui-switch.mui-switch-anim:before {
transition: left 0.3s;
}
.mui-switch.mui-switch-anim:checked {
box-shadow: #64bd63 0 0 0 16px inset;
background-color: #64bd63;
transition: border ease 0.4s, box-shadow ease 0.4s, background-color ease 1.2s;
}
.mui-switch.mui-switch-anim:checked:before {
transition: left 0.3s;
}
<input class="switch switch-anim containerPagingStatusChild" status="0" type="checkbox" />
.switch {
width: 57px;
height: 28px;
position: relative;
border: 1px solid #dfdfdf;
background-color: #fdfdfd;
box-shadow: #dfdfdf 0 0 0 0 inset;
border-radius: 20px;
background-clip: content-box;
display: inline-block;
-webkit-appearance: none;
user-select: none;
outline: none;
cursor: pointer;
}
.switch:before {
content: '';
width: 26px;
height: 26px;
position: absolute;
top: 0;
left: 0;
border-radius: 20px;
background-color: #fff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.switch:checked {
border-color: #4B74FF;
box-shadow: #4B74FF 0 0 0 16px inset;
background-color: #4B74FF;
}
.switch:checked:before {
left: 30px;
}
.switch.switch-anim {
transition: border cubic-bezier(0, 0, 0, 1) 0.4s, box-shadow cubic-bezier(0, 0, 0, 1) 0.4s;
}
.switch.switch-anim:before {
transition: left 0.3s;
}
.switch.switch-anim:checked {
box-shadow: #4B74FF 0 0 0 16px inset;
background-color: #4B74FF;
transition: border ease 0.4s, box-shadow ease 0.4s, background-color ease 1.2s;
}
.switch.switch-anim:checked:before {
transition: left 0.3s;
}
标签:CSS,格式化样式,兼容样式,常用样式,switch开关
更多演示案例,查看 案例演示
欢迎评论留言!