gpt4 book ai didi

html - 更改一个元素的 CSS 会影响 div 之外的其他元素

转载 作者:太空宇宙 更新时间:2023-11-04 16:03:53 25 4
gpt4 key购买 nike

每当我尝试向上或向下移动分隔符时,.separator 类上方的元素 h1 开始与分隔符一起移动。有什么简单的方法可以解决这个问题吗?

下面是我的 HTML/CSS 代码

.banner img {
width: 100%;
height: 100%;
}
.banner {
position: relative;
margin: -0.6%
}
.OverLay {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
}
.OverLayContent {
width: 100%;
height: 100%;
display: table;
}
.overLayDescription {
width: 70%;
margin: 0 auto;
}
.OverLayText {
width: 100%;
height: 100%;
display: table-cell;
vertical-align: middle;
text-align: center;
}
.OverLayText h1 {
margin-bottom: 5%;
color: #FFF;
font-size: 120px;
/*border-bottom: 2px solid #15a4fa;*/
}
.separator {
margin: 0 auto;
width: 50%;
background-color: #15a4fa;
height: 2px;
margin-bottom: 10.4%;
}
.OverLayText a {
color: #FFF;
border: 1px solid #15a4fa;
padding: 10px;
}
.OverLayText p {
color: #FFF;
margin-top: 2%;
margin-bottom: 3%;
}
.OverLayContent {
position: relative;
}
<div class="banner">
<img src="http://cometoart.com/wp-content/uploads/2016/03/pojo-placeholder-2.png" />
<div class="OverLay">
<div class="OverLayContent">
<div class="OverLayText">
<h1>STRICT</h1>
<dir class="separator"></dir>
<p>STRICT is a responsive theme with a a clean and minimal look.</p>
<a href="#">Call to action</a>
</div>
</div>
</div>
</div>

最佳答案

只是因为您正在使用 .OverLayTextvertically-align:middle;

关于html - 更改一个元素的 CSS 会影响 div 之外的其他元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39631143/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com