css实现下拉框

CSS:

a, label {
display: block;
border-bottom: 1px solid #ccc;
padding: 1em 2em;
width: 100%;
color: #000;
text-decoration: none;
cursor: pointer;
}

.all-items {
display: none;
}

.show-all {
display: none;
}

.list {
position: relative;
padding-bottom: 3.188em;
}

label {
position: absolute;
bottom: 0;
}

label:before {
content: "More";
}

.show-all:checked ~ .all-items {
display: block;
}

.show-all:checked + label:before {
content: "Less";
}

 

HTML:

<div class="list">
<a href="#">Micket</a>
<a href="#">Mace Windu</a>
<a href="#">Count Dooku</a>
<a href="#">Admiral Ackbar</a>
<a href="#">Padme Amidala</a>

<input id="show-all" class="show-all" type="checkbox" />
<label for="show-all"></label>

<div class="all-items">
<a href="#">Gamorrean Guards</a>
<a href="#">C-3P0</a>
<a href="#">Qui-Gin Jinn</a>
<a href="#">Imperial Guards</a>
<a href="#">Obi-Wan Kenobi</a>
<a href="#">Tie Fighter Pilot</a>
<a href="#">Greedo</a>
</div>
</div>

不兼容IE6、7、8 

转自:http://modernweb.com/2014/07/30/5-things-wont-believe-built-css/

css实现下拉框,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。