我正在开发一个程序列表,如果单击某个按钮,则会打开一个框并显示信息文本。我只是使用CSS过渡,但它们似乎不起作用,我不知道问题出在哪里,所以也许你们可以提供帮助?提前谢谢!
这是JSFidlle: https://jsfiddle.net/g3v0q11L/1/
HTML
<div class="program">
<div class="pblock">
<div class="pb-top">
<div class="date">Di. 23 Aug.</div>
</div>
<div class="pb-bottom">
<div class="info">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta.
Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean
quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris
ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
</div>
</div>
<div class="opener"></div>
</div>
</div>
JQuery的
$(document).ready(function() {
$('.opener').click(function() {
$('.opener').toggleClass('turn');
$('.info').toggleClass('there');
$('.pb-bottom').toggleClass('opened');
});
});
CSS
.program {
position: relative;
width: 100vw;
height: 100vh;
background-color: red;
}
.pblock {
top: 100px;
position: relative;
left: calc(50% - 45vw);
width: 90vw;
height: auto;
min-height: 150px;
margin: 0;
padding: 0;
}
.pb-top {
position: relative;
height: 100px;
}
.date {
color: white;
font-size: 1.3em;
font-family: 'FBold';
display: inline;
position: absolute;
top: 70px;
}
.pb-bottom {
position: relative;
-webkit-transition: all 1s ease-out;
transition: all 1s ease-out;
height: 0px;
border-top: 1px solid white;
border-bottom: 1px solid white;
}
.opened {
height: auto !important;
}
.info {
-webkit-transition: all 1s ease-out;
transition: all 1s ease-out;
display: none;
opacity: 0;
}
.there {
display: block;
opacity: 1;
}
.opener {
position: relative;
top: 10px;
width: 50px;
left: calc(50% - 25px);
height: 40px;
background: rgba(255, 255, 255, 0.5);
border-bottom: 2px solid purple;
transition: transform 0.2s ease-in-out;
transform-origin: center;
animation: flicker 3s ease-in-out infinite;
}
.turn {
transform: rotate(180deg);
}
@keyframes flicker {
0% {
opacity: 1;
}
50% {
opacity: 0.4;
}
100% {
opacity: 1;
}
}