【发布时间】:2019-09-05 14:09:01
【问题描述】:
我有一个无序列表的图像,每个图像的底部都有一个文本覆盖。文本覆盖是具有不同背景颜色的内嵌块。
首先,我在不需要的背景颜色之间得到一个空白。 ✔️
其次,左边的内联块有一个固定的宽度,而右边需要覆盖剩余的宽度✔️
第三,第二个块应该有另一个隐藏的元素,应该在悬停时显示
最后我希望这两个块在它们中的任何一个高度发生变化时始终具有均匀的高度
编辑 段落 div 需要在悬停时显示。此外,我希望内联块的高度即使在它们中的任何一个发生变化时也会出现。
这是我目前所拥有的
.slideList {
width: 100%;
}
.slideList li {
position:relative;
}
.slideList .service-highlight {
position: absolute;
color: white;
bottom: 0;
left: 0;
right:0
}
.slideList .service-highlight p {
display: inline-block;
color: white;
font-size: 18px;
font-weight: bold;
}
.slideList .service-highlight .services-box{
text-align: center;
background-color: #003768;
width: 200px;
font-weight: bold;
float: left;
}
.slideList .service-highlight .services-detail{
background-color: #0088ff;
width:calc(100% - 200px);
float: left;
padding-left: 5px;
}
.slideList .hide-description {
display: none;
font-weight:normal;
}
.slideList .hide-description p {
font-weight:normal;
padding-top: 10px 5px 10px;
}
.services-detail:hover + .hide-description {
display: block;
position: absolute;
}
.clearFloat {
clear: both;
}
<ul class="slideList">
<li data-transition="fade">
<img src="https://images.unsplash.com/photo-1532274402911-5a369e4c4bb5?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=750&q=80" >
<div class="service-highlight">
<p class="services-box">SOME SERVICE:</p>
<div class="services-detail">
<p>Some headline</p>
<div class="hide-description">
<p>Some text that appears here. Text describes some service I intend to achieve. This may or may not take up to three lines maybe two </p>
</div>
</div>
</div>
</li>
<ul>
【问题讨论】:
-
您粘贴的 div 没有分配背景颜色
-
我在打字时错过了一节课。现在有。
-
@Gosi 它解决了一些并非全部的挑战,因此我投了赞成票。