大家在使用select的時候有沒有發現一個問題:固定樣式很難隱藏掉,只能通過設置寬度,然後再設置overflow:hidden來隱藏固定的下拉標籤
這裏是一個用a標籤結合有序列表來實現select
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
color: #43853d;
}
a{
display: block;
text-decoration: none;
}
a:hover{
background-color: #43853d;
color: #fff;
}
a:hover span{
color:#fff;
}
.select{
width: 140px;
position: relative;
zoom: 1;
}
ol{
width: 100%;
border: 1px solid #43853d;
display: none;
position: absolute;
list-style: none;
}
.select:hover ol{
display: block;
/* overflow: hidden; */
}
ol li a{
padding-left: 20px;
}
.select:after{
content:"";
clear: both;
height: 0;
display: block;
visibility: hidden;
}
</style>
</head>
<body>
<h1>ssda1</h1>
<div class="select">
<a href="">
"查看其它版本"
<span>▼</span>
</a>
<ol>
<li>
<a href="">1.1</a>
</li>
<li>
<a href="">1.2</a>
</li>
</ol>
</div>
</body>
</html>