gpt4 book ai didi

html - 如何强制我的导航和按钮保持恒定高度?

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

我有以下代码

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

/*header*/
.header {

padding: 2.5vw;
position: relative;
background: linear-gradient(to right, #EE7752 25%, #E73C7E 50%, #23A6D5 75%, #23D5AB 100%);
background-size: 200% 200%;
animation: Gradiente 15s ease infinite;
font-size:15px;
}

@keyframes Gradiente {
0% {
background-position: 0% 50%
}

50% {
background-position: 100% 50%
}

100% {
background-position: 0% 50%
}
}

.header p {
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%)
}

/*navbar*/
.flex {
display: flex;
flex-direction: row;
width: 100%;

}

.option {
display: flex;
width: 24.7%;
color: white;
background-color: grey;
justify-content: center;
align-items: center;
height: 4vw;
margin-left:0.25vw;

}
#menu{
display:none;
}


</style>
</head>

<body>

<section class="container1">
<div class="header">
<h1><p>Examen B 2DAW</p></h1>
</div>

<nav>
<div class="flex">
<div id="menu">Menú</div>
<div class="option"><a href="#"></a>Opcion 1</div>
<div class="option"><a href="#"></a>Opcion 2</div>
<div class="option"><a href="#"></a>Opcion 3</div>
<div class="option"><a href="#"></a>Opcion 4</div>
</div>
</nav>

</section>


</body>

</html>

当收缩时它的高度会降低,这是我不希望发生的事情,因为我希望它保持恒定的高度

我的缩小后是这样的

Mine is shrinked

但它应该看起来像这样(保持它的高度),我尝试用 px 和 vw 设置高度,但它没有什么不同。我试过使用不同的字体大小,但我无法解决这个问题。我需要它保持高度,同时在水平方向上变小,为什么它没有发生?

enter image description here

最佳答案

在你的 headernav 类中,只需设置一个 min-height

例子:

min-height:60px;

关于html - 如何强制我的导航和按钮保持恒定高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59146381/

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