html - 悬停时段落在我的 div 之外重叠
问题描述
我正在尝试在我的视频下方添加一个黑色容器,并在悬停时在该黑色容器内添加标题和描述,但与黑色容器重叠的描述如何将其保留在黑色容器内。
.previewContainer.small {
position: relative;
width: 230px;
height: 129px;
margin-right: 4px;
display: inline-flex;
transition: 0.5s ease;
overflow: hidden;
white-space: nowrap;
flex: 1 1 0px;
transition: transform 500ms;
}
.title{
display: none;
}
.previewContainer.small:focus-within,
.previewContainer.small:hover{
margin-left: 65px;
transform: translateY(-50%) translateX(-50%);
z-index: 1;
width: 230px;
height: 250px;
background-color: #141414;
border-radius: 5px;
}
.small:focus ~ .small,
.small:hover ~ .small {
transform: translateX(25%);
}
.previewContainer.small:focus,
.previewContainer.small:hover {
transform: scale(1.6);
z-index: 1;
}
.Play{
position: absolute;
width: 100%;
display: flex;
margin-left: 10px;
background-color: transparent;
font-size: 10px;
padding: 0px;
transition-duration: 1s;
}
.title{
position: absolute;
text-transform: capitalize;
width: 100%;
display: flex;
margin-left: 10px;
background-color: transparent;
font-size: 5px;
transition-duration: 1s;
}
.description{
position: absolute;
display: flex;
padding-top: 30px;
margin-left: 10px;
background-color: transparent;
text-decoration:none;
overflow: hidden;
color: white;
}
.title h6{
color:#fff !important;
font-weight: 300;
font-size: 14px;
}
.video-item {
position: relative;
max-width: 100%;
transition: transform 0.2s;
z-index: 1;
cursor: pointer;
border-radius: 4px;
object-fit: cover;
}
<div class="previewContainer">
<div class="previewContainer small">
<a href"">
<video class="mylist-img video-item" onmouseover="this.play()" onmouseout="this.pause();">
<source src="https://sgcholdings.co.za/Backend/media/sample-30s.mp4">
Your browser does not support the video tag.
</video>
<div class="title">
<h6>Video One</h6>
</div>
<div class="description">
<p class="">Loren ipsum dolor sit amet because there are two,
there is web version which works on hover with a small pop up then </p>
</div>
</a>
</div>
</div>
所以我想将描述包含在我悬停时出现的黑色背景中。有人可以帮助如何包含段落标签不重叠
解决方案
您可以使用以下代码更新您的 CSS
.description {
white-space: normal;
}
white-space:normal
空白序列被折叠。源中的换行符的处理方式与其他空格相同。必要时换行以填充行框。
推荐阅读
- .htaccess - 如何将 https://www.hhl.com/articlename.html?a=b 重定向到 https://www.hhl.com/articlename/?a=b
- iis - 存在 ADFS 401 问题的 SSO
- python - 列表和数组的形状以及如何在输入和输出中使用它们
- python - 如何找到 n 维 numpy 数组的第 i 个最大元素的索引?
- r - 从期权链中找到最接近当前股票价格的行使价。
- java - 减去圆弧的内半径/部分以实现环形进度条
- ruby - 将数组的元素添加到数组数组中每个数组的特定索引
- apache-kafka - Kafka - 保留期参数
- swift - 如何在 iOS 应用中存储和更新 .p12 证书?
- git - 为什么每次打开新的终端窗口都必须重新输入这些命令才能让 Git 工作?