HTML
<body>
<header>
<nav class="navigation">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Product</a></li>
<li><a href="#">Faq</a></li>
<li><a href="#">Contact</a></li>
</ul>
<div class="menu-burger">
<div class="hline"></div>
<div class="hline"></div>
<div class="hline"></div>
</div>
</nav>
</header>
<main class="main-section">
<div class="main-section-container">
<p id="line-1">Food app</p>
<p id="line-main">Why stay hungry when you can order form Bella Onojie</p>
<p id="line-3">Download the bella onoje’s food app now on</p>
<div class="btn-container">
<button class="btn1">Playstore</button>
<button class="btn2">App store</button>
</div>
</div>
</main>
<section class="section-a">
</section>
</body>CSS
html,body{
box-sizing: border-box;
}
/*---------------------------------NavBar------------------------------------------------*/
header{
width: 100%;
height: 156px;
}
.navigation{
width: 100%;
height: 100%;
display: flex;
align-items: center;
padding: 0px 50px;
}
.hline{
width: 20px;
height: 3px;
background-color: var(--clr-4);
margin: 3px 0px;
border-radius: 4px;
}
.menu-burger{
display: none;
cursor: pointer;
}
.navigation a{
text-decoration: none;
color: var(--clr-3);
font-family: var(--font-1);
font-weight: 600;
font-size: 1rem;
transition: 0.3s ease;
}
.navigation a:hover{
color: var(--clr-2);
}
.navigation ul{
margin-left: auto;
list-style: none;
display: flex;
width: 50%;
max-width: 720px;
justify-content: space-between;
}
@media (max-width: 600px){
header{
height: 112px;
}
.menu-burger{
display: inline-block;
margin-left: auto;
}
.navigation{
padding: 0px 24px;
}
.navigation ul{
display: none;
}
}
/*----------------------------Main Section-------------------------------------------------*/
.main-section{
width: 100%;
min-height: 619px;
max-height: 750px;
background-image: url(../images/main-bg.png);
background-size: cover;
position: relative;
overflow: hidden;
background-repeat: no-repeat;
}
.main-section::after{
content: "";
height: 100%;
width: 100%;
background-color: var(--clr-5);
position: absolute;
top: 0;
left: 0;
opacity: 0.7;
z-index: 1;
}
.main-section-container{
position: relative;
z-index: 2;
width: 60%;
margin: 0 auto;
display: flex;
flex-direction: column;
align-items: center;
top: 80px;
}
#line-1{
font-family: var(--font-1);
font-size: var(--font-size-3);
font-weight: 700;
color: var(--clr-1);
margin-bottom: 20px;
}
#line-main{
font-family: var(--font-3);
font-size: var(--font-size-7);
font-weight: 700;
color: var(--clr-1);
line-height: 5rem;
margin-bottom: 40px;
text-align: center;
}
#line-3{
font-family: var(--font-1);
font-size: var(--font-size-3);
font-weight: 500;
color: var(--clr-1);
margin-bottom: 40px;
text-align: center;
}
.btn-container{
display: flex;
width: 500px;
justify-content: space-between;
}
.btn1, .btn2{
font-family: var(--font-1);
font-size: var(--font-size-3);
font-weight: 700;
color: var(--clr-1);
width: 236px;
height: 68px;
border-radius: 30px;
outline: none;
cursor: pointer;
}
.btn1{
background-color: var(--clr-2);
border: none;
}
.btn2{
background: none;
border: 2px solid var(--clr-1);
}
@media (max-width: 850px){
#line-1{
font-size: var(--font-size-2);
}
#line-main{
font-size: var(--font-size-4);
line-height: 2.65rem;
}
}
@media (max-width: 700px){
.btn-container{
width: 236px;
flex-direction: column;
}
.btn1, .btn2{
margin: 10px 0px;
}
}
@media (max-width: 600px){
.main-section{
background-image: none;
background-color: var(--clr-6);
}
.main-section::after{
background-color: none;
background: none;
}
#line-1{
color: var(--clr-4);
}
#line-main{
color: var(--clr-5);
}
#line-3{
color: var(--clr-4);
}
.btn-container{
width: 236px;
flex-direction: column;
}
.btn1, .btn2{
margin: 10px 0px;
}
.btn2{
color: var(--clr-2);
border-color: var(--clr-2)
}
}
@media (max-width:500px){
.main-section{
min-height: 650px;
}
}
/*----------------------------------Section a------------------------------------------*/
.section-a{
width: 100%;
height: 50vh;
background-color: var(--clr-1);
}我的问题是当我试图使它响应时,当它达到454px时,主要的两个按钮隐藏起来。因为主节没有伸展。
为了了解我的问题,我附上了一些截图。



我该如何解决这个问题?我想拉伸主部分,并在减小尺寸时保持按钮可见。(主要部分为浅灰色背景。)
非常感谢你的帮助!
发布于 2020-11-27 22:29:30
你必须以较低的分辨率重置top style:.main-section-container {top: 0;},或者可以删除overflow: hidden。
html,body{
box-sizing: border-box;
}
/*---------------------------------NavBar------------------------------------------------*/
header{
width: 100%;
height: 156px;
}
.navigation{
width: 100%;
height: 100%;
display: flex;
align-items: center;
padding: 0px 50px;
}
.hline{
width: 20px;
height: 3px;
background-color: #ccc;
margin: 3px 0px;
border-radius: 4px;
}
.menu-burger{
display: none;
cursor: pointer;
}
.navigation a{
text-decoration: none;
color: var(--clr-3);
font-family: var(--font-1);
font-weight: 600;
font-size: 1rem;
transition: 0.3s ease;
}
.navigation a:hover{
color: var(--clr-2);
}
.navigation ul{
margin-left: auto;
list-style: none;
display: flex;
width: 50%;
max-width: 720px;
justify-content: space-between;
}
@media (max-width: 600px){
header{
height: 112px;
}
.menu-burger{
display: inline-block;
margin-left: auto;
}
.navigation{
padding: 0px 24px;
}
.navigation ul{
display: none;
}
}
/*----------------------------Main Section-------------------------------------------------*/
.main-section{
width: 100%;
min-height: 619px;
max-height: 750px;
background-image: url(../images/main-bg.png);
background-size: cover;
position: relative;
overflow: hidden;
background-repeat: no-repeat;
}
.main-section::after{
content: "";
height: 100%;
width: 100%;
background-color: var(--clr-5);
position: absolute;
top: 0;
left: 0;
opacity: 0.7;
z-index: 1;
}
.main-section-container{
position: relative;
z-index: 2;
width: 60%;
margin: 0 auto;
display: flex;
flex-direction: column;
align-items: center;
top: 80px;
}
#line-1{
font-family: var(--font-1);
font-size: var(--font-size-3);
font-weight: 700;
color: var(--clr-1);
margin-bottom: 20px;
}
#line-main{
font-family: var(--font-3);
font-size: var(--font-size-7);
font-weight: 700;
color: var(--clr-1);
line-height: 5rem;
margin-bottom: 40px;
text-align: center;
}
#line-3{
font-family: var(--font-1);
font-size: var(--font-size-3);
font-weight: 500;
color: var(--clr-1);
margin-bottom: 40px;
text-align: center;
}
.btn-container{
display: flex;
width: 500px;
justify-content: space-between;
}
.btn1, .btn2{
font-family: var(--font-1);
font-size: var(--font-size-3);
font-weight: 700;
color: var(--clr-1);
width: 236px;
height: 68px;
border-radius: 30px;
outline: none;
cursor: pointer;
}
.btn1{
background-color: #ddd;
border: none;
}
.btn2{
background: none;
border: 2px solid var(--clr-1);
}
@media (max-width: 850px){
#line-1{
font-size: var(--font-size-2);
}
#line-main{
font-size: var(--font-size-4);
line-height: 2.65rem;
}
}
@media (max-width: 700px){
.btn-container{
width: 236px;
flex-direction: column;
}
.btn1, .btn2{
margin: 10px 0px;
}
}
@media (max-width: 600px){
.main-section{
background-image: none;
background-color: #ccc;
}
.main-section::after{
background-color: none;
background: none;
}
#line-1{
color: var(--clr-4);
}
#line-main{
color: var(--clr-5);
}
#line-3{
color: var(--clr-4);
}
.btn-container{
width: 236px;
flex-direction: column;
}
.btn1, .btn2{
margin: 10px 0px;
}
.btn2{
color: var(--clr-2);
border-color: var(--clr-2)
}
}
@media (max-width:500px){
.main-section{
min-height: 650px;
}
.main-section-container {
top: 0;
}
}
/*----------------------------------Section a------------------------------------------*/
.section-a{
width: 100%;
height: 50vh;
background-color: #ddd;
}<body>
<header>
<nav class="navigation">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Product</a></li>
<li><a href="#">Faq</a></li>
<li><a href="#">Contact</a></li>
</ul>
<div class="menu-burger">
<div class="hline"></div>
<div class="hline"></div>
<div class="hline"></div>
</div>
</nav>
</header>
<main class="main-section">
<div class="main-section-container">
<p id="line-1">Food app</p>
<p id="line-main">Why stay hungry when you can order form Bella Onojie</p>
<p id="line-3">Download the bella onoje’s food app now on</p>
<div class="btn-container">
<button class="btn1">Playstore</button>
<button class="btn2">App store</button>
</div>
</div>
</main>
<section class="section-a">
</section>
</body>
https://stackoverflow.com/questions/65038431
复制相似问题