自定义(滑动条)横的
可以去除浏览器默认样式,但却是一个不规范的属性(unsupported WebKit property),
它没有出现在 CSS 规范草案中,此属性非标准且渲染效果在不同浏览器下不同,有些属性值甚至不支持,请慎用。
input[type="range"] {
-webkit-appearance: none;
width: 100%;
margin: 0;
background: transparent;
}
input[type="range"]:focus {
outline: none;
}
/*滑道*/
input[type="range"]::-webkit-slider-runnable-track {
background: transparent;
border: none;
}
/*滑块*/
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 12px;
height: 12px;
border-radius: 50%;
margin-bottom: 15px;
background-color: transparent;
box-shadow: 0 0 0 3px white, 0 1px 3px 3px rgba(5, 10, 70, 0.33);
}
自定义(滚动条)竖的
/*滑道*/
::-webkit-scrollbar-track
{
border-radius: 10px;
background-color: #fff;
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
}
/*滑动条*/
::-webkit-scrollbar
{
width: 7px;
background-color: #fff00;
}
/*滑块*/
::-webkit-scrollbar-thumb
{
border-radius: 10px;
background-color: #b3b3b3;
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
/*background:linear-gradient(to bottom,red,#ffe607,#fffa04,#0fff4e,#00a1ff,#ef00ff); */
}
自定义(单选框)
input[type="radio"] {
appearance: none;
-webkit-appearance: none;
outline: none;
margin: 0;
}
input[type="radio"]:after {
display: block;
content: "";
width: 12px;
height: 12px;
background: #fff;
border-radius: 50%;
border: 2px solid #bfbfbf;
}
/*已选择*/
input[type="radio"]:checked:after {
background: #0593d3;
border: 2px solid #fff;
}
设置input 中placeholder的样式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
/* Chrome/Opera/Safari */
::-webkit-input-placeholder {
color: red;
}
/* Firefox 19+ */
::-moz-placeholder {
color: red;
}
/* IE 10+ */
:-ms-input-placeholder {
color: red;
}
/* Firefox 18- */
:-moz-placeholder {
color: red;
}
</style>
</head>
<body>
<input type="" name="" placeholder="提示内容">
</body>
</html>
设置input input[type="search"]的取消按钮
input[type="search"]::-webkit-search-cancel-button {
-webkit-appearance: none;
position: relative;
height: 0.9rem;
width: 0.9rem;
border-radius: 50%;
background: #ebebeb url("../../assets/img/del.png") no-repeat center;
background-size: 0.8rem 0.8rem;
}