【发布时间】:2021-12-24 13:13:55
【问题描述】:
所以我正在为不存在的游戏做一个练习登陆页面,这就是我遇到的问题。
hero-row div 溢出其 header-box 容器,因为它本身已被其内容溢出
header-box 包含 2 行:nav-row 和 hero-row。它们显示为弹性项目,并且它们本身在内部使用弹性布局。该问题似乎与图像azamat-icon 的填充有关。请帮我把头绕过去,因为这会使hero-row 的内容低于必要的水平,并且header-box 大于屏幕高度,尽管heigth: 100vh。
Screenshot
这部分项目的代码:
.header-box {
background-color: grey;
color: black;
margin: 0 auto;
height: 100vh;
}
/************* Nav Bar **************/
.nav-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 2rem 6rem;
}
.nav-ul {
font-family: 'bold';
list-style: none;
display: flex;
}
.nav-item {
margin-left: 7rem;
cursor: pointer;
}
/************* Nav Bar **************/
/************* Logo **************/
.logo {
font-family: 'scbold';
font-size: 2rem;
cursor: pointer;
}
/************* Logo **************/
/******************* Hero Starts ************************/
.hero-row {
font-family: 'bold';
display: flex;
width: 100%;
overflow: hidden;
}
.hero-content {
flex: 0 0 50%;
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
overflow: hidden;
padding: 0 5%;
max-height: inherit;
}
.hero-azamat {
flex: 0 0 50%;
overflow: hidden;
padding: 10%;
max-height: inherit;
}
.azamat-icon {
width: 100%;
}
.hero-description {
font-size: 1.5rem;
padding-right: 25%;
margin: 5% 0 10%;
letter-spacing: 0.01rem;
}
<header>
<div class="header-box">
<nav class="nav-row">
<h1 class="logo">LOGO</h1>
<ul class="nav-ul">
<li class="nav-item">About</li>
<li class="nav-item">Merch</li>
<li class="nav-item">Purchase</li>
</ul>
</nav>
<div class="hero-row">
<div class="hero-content">
<h1 class="hero-heading">
Start your adventure!
</h1>
<p class="hero-description">
The game is so good and tasty mmm you should definitely try it out baby come on oh i love Freddie Mercury btw
</p>
<button class="hero-btn">Buy Now!</button>
</div>
<div class="hero-azamat">
<img src="images\164-1648549_8-bit-mario-png-mario-8-bit-png.png" alt="" class="azamat-icon">
</div>
</div>
</div>
</header>
如您所见,我尝试了一些方法来解决 overflow: hidden 的问题,但没有奏效。
【问题讨论】:
标签: html css layout flexbox overflow