gpt4 book ai didi

html - 使我的标题 "fixed"调整标题框的大小

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

我想做一个固定标题,左边是可点击的链接,右边是我们的标志。

将文本 + 图像 float 到相应位置并使页眉占据整个屏幕宽度没有问题。一旦我使其“固定”,标题的宽度就会缩小到我添加的 3 个链接的宽度。

页眉的宽度已经设置为 100%,我似乎找不到潜在的问题是什么

html {
scroll-behavior: smooth;
}

.clear {
clear: both;
}

header {
width 100%;
height: 100px;
position: fixed;
color: rgb(255, 0, 0);
top: 0;
left: 0;
box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.1);
z-index: 999;
}

footer {
height: 30px;
color: black;
text-align: center;
box-shadow: 1px 0 4px 0 rgba(0, 0, 0, 0.1);
}

header ul {
list-style: none;
float: left;
text-transform: uppercase;
font-family: 'Source Sans Pro';
font-weight: bold;
}

header ul li {
float: left;
margin-left: 60px;
line-height: 100px;
}

header ul a {
text-decoration: none;
}

header ul a:hover {
color: rgb(200, 0, 0);
}

.thumb-container {
max-width: calc(960px + 40px);
margin: 110px auto 0 auto;
}

.thumb-container a {
width: calc(960px / 3);
height: calc(960px / 3);
background: aqua;
float: left;
margin: 0 5px 10px 5px;
}

@media screen and (max-width: 1000px) {
.thumb-container {
max-width: 660px;
/* in midden zetten */
background: black;
}
}

@media screen and (max-width: 660px) {
.thumb-container {
max-width: 100%;
/* in midden zetten */
background: black;
}
.thumb-container a {
width: 100%;
/* maakt containers volledige breedte*/
margin: 0 0 10px 0;
}
}
<header>
<nav>
<ul>
<li> <a href="index.html"> Home </a></li>
<li> <a href="#"> Benodigdheden </a></li>
<li> <a href="#"> Over ons </a></li>
</ul>
</nav>

<img src="img/" alt="lol">

</header>

<main>

<div class="thumb-container">

<a href="#"> </a>
<a href="#"> </a>
<a href="#"> </a>
<a href="#"> </a>
<a href="#"> </a>
<a href="#"> </a>

<div class="clear"></div>

</div>



</main>


<footer> Test footer text</footer>

最佳答案

试试这个

body {margin:0;}

.navbar {
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
}

.navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}

.navbar a:hover {
background: #ddd;
color: black;
}

.main {
padding: 16px;
margin-top: 30px;
height: 1500px;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>

<div class="navbar">
<a href="#home">Home</a>
<a href="#news">Benodigdheden</a>
<a href="#contact">Contact</a>
</div>

<div class="main">
<p>Some text some text some text some text..</p>
<p>Some text some text some text some text..</p>
</div>

</body>
</html>

关于html - 使我的标题 "fixed"调整标题框的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56199738/

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