我设计了一个带有css关键帧的字幕包装器。但字幕内容没有显示。
我是根据https://codepen.io/nickcil/pen/BygPMY
设计的但是不知道为什么字幕内容没有显示出来。 动画和所有这些东西都可以正常工作。 先生,请帮助我确定问题所在。
.landing-ratecard-wrapper {
position: relative;
padding: 15px 20px;
background-color: rgba(0, 0, 0, 0.45);
border-radius: 4px;
margin-top: 40px;
}
.landing-ratecard-wrapper .ratecard-title {
color: #fff;
font-weight: 500;
font-size: 18px;
margin: 0;
}
.landing-ratecard-wrapper .marquee {
flex-grow: 1;
overflow: hidden;
box-sizing: border-box;
position: relative;
}
.landing-ratecard-wrapper .marquee .marquee--inner {
display: block;
width: 200%;
position: absolute;
top: -15px;
animation: marquee 20s linear infinite;
}
.landing-ratecard-wrapper .marquee .marquee--inner span {
width: 50%;
float: left;
}
.landing-ratecard-wrapper .marquee .marquee--inner span .rate {
width: 200px;
display: inline-block;
margin: 0 10px;
float: left;
transition: all 0.2s ease-out;
color: #fff;
}
.landing-ratecard-wrapper .marquee .marquee--inner:hover {
animation-play-state: paused;
}
@keyframes marquee {
0% {
left: 0;
}
100% {
left: -100%;
}
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.bundle.min.js"></script>
<div class="landing-ratecard-wrapper d-flex align-items-center justify-content-between">
<h5 class="ratecard-title">Rate Card</h5>
<div class="marquee">
<div class="marquee--inner">
<span>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
</span>
<span>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
</span>
</div>
</div>
</div>
答案 0 :(得分:1)
您缺少身高
.landing-ratecard-wrapper .marquee {
flex-grow: 1;
overflow: hidden;
box-sizing: border-box;
position: relative;
height: 150px;
}
还在类landing-ratecard-wrapper .marquee .marquee--inner
中将top设置为0
.landing-ratecard-wrapper {
position: relative;
padding: 15px 20px;
background-color: rgba(0, 0, 0, 0.45);
border-radius: 4px;
margin-top: 40px;
}
.landing-ratecard-wrapper .ratecard-title {
color: #fff;
font-weight: 500;
font-size: 18px;
margin: 0;
}
.landing-ratecard-wrapper .marquee {
flex-grow: 1;
overflow: hidden;
box-sizing: border-box;
position: relative;
height: 150px;
}
.landing-ratecard-wrapper .marquee .marquee--inner {
display: block;
width: 200%;
position: absolute;
top: 0;
animation: marquee 20s linear infinite;
}
.landing-ratecard-wrapper .marquee .marquee--inner span {
width: 50%;
float: left;
}
.landing-ratecard-wrapper .marquee .marquee--inner span .rate {
width: 200px;
display: inline-block;
margin: 0 10px;
float: left;
transition: all 0.2s ease-out;
color: #fff;
}
.landing-ratecard-wrapper .marquee .marquee--inner:hover {
animation-play-state: paused;
}
@keyframes marquee {
0% {
left: 0;
}
100% {
left: -100%;
}
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.bundle.min.js"></script>
<div class="landing-ratecard-wrapper d-flex align-items-center justify-content-between">
<h5 class="ratecard-title">Rate Card</h5>
<div class="marquee">
<div class="marquee--inner">
<span>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
</span>
<span>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
<div class="rate">lorem ipsum</div>
</span>
</div>
</div>
</div>
希望这会有所帮助。