【发布时间】:2021-12-17 03:42:14
【问题描述】:
文本的顶部应该与图像的顶部一致,但事实并非如此。为什么? 我让这两个 div 重叠。它们之间的唯一区别是宽度(一个设置为 50%,另一个设置为 100%),但是当涉及到这个问题时,改变宽度并不会改变任何事情。我将文本 div 设为 50%,因为我希望文本不与图像上的植物接触。 The circled area of this image isn't supposed to be empty
It's even worse on small screens. The text here overlaps the footer (It shouldnt)
.intro-img-div{
position: relative;
height: 300px;
width: 100%;
overflow: hidden;
align-content: center;
margin:auto;
display: flex;
justify-content: center;
align-items: center;
}
.menu-intro-img{
position: relative;
width: 100%;
}
.menu-intro-text{
position: absolute;
top: 0;
right: 0;
z-index: 2;
vertical-align: middle;
max-width: 50%;
height: 300px;
margin-bottom: 30px;
margin: 20px;
padding: 20px;
text-align: center;
}
.menu-intro-h1{
font-size: 3em;
}
.menu-intro-text p{
font-size: 1.5em;
}
<main>
<h1 class="text-centered">Our Menu</h1>
<div class="menu">
<div class="menu-intro">
<div class="intro-img-div">
<img src="style/img/menuintroimg.jpeg" alt="Background image of our food" class="menu-intro-img">
</div>
<div class="menu-intro-text">
<h1 class="menu-intro-h1">A look at <span class="red-text">Jacque's</span>
</h1>
<p>Scroll down and see what we have to offer!</p>
</div>
</div>
</div>
</main>
【问题讨论】:
标签: html css responsive-design frontend