我将一个简单的手风琴放入一个基于bootstrap的简单响应式网站。
<div class="container">
<div class="row">
<div class="accordion">
<!--<h1>Descirption</h1>-->
<ul class="features_list">
<li>
<input type="checkbox" checked>
<i></i>
<h2>Lorem ipsum dolor sit amet</h2>
<p>sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,</p>
</li>
工作正常,好的。但是现在我想要一些手风琴在装载时打开,而其中一些手风琴会保持关闭状态。只是在CSS中。
有什么想法吗?
到目前为止,谢谢。
答案 0 :(得分:0)
您可以在已选中的折叠中设置第一个复选框,而另一个复选框保持未选中状态。然后在css中添加行为以打开被检查的手风琴。
------------- HTML ------------
<div id="wrapper">
<ul>
<li>
<input type="checkbox" >
<i></i>
<h2>What is Lorem Ipsum ?</h2>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</li>
<li>
<input type="checkbox" checked>
<i></i>
<h2>Why do we use it ?</h2>
<p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).</p>
</li>
<li>
<input type="checkbox" checked>
<i></i>
<h2>Wher we can it ?</h2>
<p>There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.</p>
</li>
</ul>
</div>
------- CSS ------
body {
width: 100%;
height: 100%;
background-color: #eeeeee;
font-family: 'Poiret One', cursive;
color: rgba(48, 69, 92, 0.8);
}
#wrapper {
min-height: 0;
display: inline-block;
position: relative;
left: 50%;
margin: 50px 0;
transform: translate(-50%, 0);
background-color: #fefffa;
max-width: 450px;
padding: 30px;
}
h1,
h2 {
color: #000000;
}
h1 {
margin: 10% auto 0;
text-transform: uppercase;
font-size: 36px;
line-height: 42px;
letter-spacing: 3px;
font-weight: 100;
text-align: center;
display: table;
padding: 10px 0;
font-weight: bolder;
border-bottom: 2px solid #000;
}
h2 {
font-size: 26px;
line-height: 34px;
font-weight: 300;
letter-spacing: 1px;
display: block;
background-color: #fefffa;
margin: 0;
cursor: pointer;
}
p {
color: rgba(48, 69, 92, 0.8);
font-size: 17px;
line-height: 26px;
letter-spacing: 1px;
position: relative;
overflow: hidden;
max-height: 800px;
opacity: 1;
transform: translate(0, 0);
margin-top: 14px;
z-index: 2;
transition: all 500ms ease;
}
p,
ul li i:before,
ul li i:after {
transition: all 0.25s ease-in-out;
}
ul {
list-style: none;
padding: 0;
margin: 0;
}
ul li {
position: relative;
padding: 0;
margin: 0;
padding-bottom: 4px;
padding-top: 18px;
border-top: 1px dotted #dce7eb;
}
ul li i {
position: absolute;
transform: translate(-6px, 0);
margin-top: 9px;
right: 0;
}
ul li i:before,
ul li i:after {
content: "";
position: absolute;
background-color: #000000;
width: 3px;
height: 16px;
}
ul li i:before {
transform: translate(2px, 0) rotate(45deg);
}
ul li i:after {
transform: translate(2px, 0) rotate(-45deg);
}
ul li input[type=checkbox] {
position: absolute;
cursor: pointer;
width: 100%;
height: 100%;
z-index: 1;
opacity: 0;
}
ul li input[type=checkbox]:checked ~ p {
margin-top: 0;
max-height: 0;
opacity: 0;
transform: translate(0, 50%);
}
ul li input[type=checkbox]:checked ~ i:before {
margin-top: 9px;
height: 9px;
transform: translate(2px, 0) rotate(45deg);
}
ul li input[type=checkbox]:checked ~ i:after {
margin-top: 9px;
height: 9px;
transform: translate(-2px, 0) rotate(-45deg);
}
这是一个有效的fiddle