【发布时间】:2018-01-29 21:38:39
【问题描述】:
我有一个框和一个“某物”按钮,每当有人将鼠标悬停在“onebysign”div 上时,元素的高度就会增加并出现一些文本,问题是文本在您将鼠标悬停在元素上后立即出现,但是当发生这种情况时,它看起来很丑,因为文本基本上是从无处出现的,当用户停止将鼠标悬停在元素上时也是如此。我希望文本出现延迟,就像 div 发生的情况一样。
HTML 和 CSS:
body {
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
background-color: #f2f2f2;
}
.events {
padding: 20px 100px;
}
.textInfo {
text-transform: uppercase;
font-weight: 600;
color: #085DAD;
padding: 10px;
background-color: white;
}
.onebyone {
background-color: grey;
width: 100%;
padding-top: 100%;
position: relative;
background-size: cover;
}
.onebytext {
position: absolute;
top: 10px;
left: 0;
bottom: 0;
right: 0;
text-align: center;
font-size: 32px;
color: white;
width: 90%;
left: 5%;
}
.onebysign {
position: absolute;
left: 0;
bottom: 0;
right: 0;
height: 60px;
text-align: center;
font-size: 20px;
background-color: white;
font-size: 24px;
transition: height 1s;
}
.onebytext,
.onebysign {
position: absolute;
text-align: center;
color: white;
}
.onebysign:hover {
height: 300px;
}
.onebyform {
left: 0;
right: 0;
bottom: 0;
position: absolute;
}
.submitBtn {
background-color: #0099CC;
text-transform: uppercase;
padding: 10px;
border-radius: 50px;
border: 0px;
width: 70%;
margin: 10px 0;
}
.onebysign:before {
content: "";
height: 30px;
width: 100%;
position: absolute;
background: linear-gradient(to top right, white 47%, transparent 50%);
left: 0;
top: -30px;
}
.signText {
display: none;
color: black;
font-size: 18px;
padding: 10px 20px;
font-weight: 600;
text-align: center;
max-width: 400px;
}
.onebysign:hover .signText {
transition-delay: 1s;
display: inline-block;
}
<div class="row events">
<div class="onebyone">
<div class="onebytext">
<div class="textInfo">Test</div>
</div>
<div class="onebysign">
<span class="signText">This is a sample text. It looks pretty good now, but the longer you make the text, the more ugly it looks...</span>
<form class="onebyform" action="<?php echo get_permalink(); ?>">
<button class="submitBtn">Something</button>
</form>
</div>
</div>
</div>
【问题讨论】: