我的网页的宽度扩展了。有什么方法可以使它变得更小?
因此,当我为网页制作标题时,由于某种原因,该网页的宽度扩展了。我尝试了一些方法来缩小它,但我没有成功。在下面,我链接了一个Codepen,您可以滚动,您会看到我创建的标头的纯白色权利。
https://codepen.io/blurfnes/pen/pen/pen/kkovggby
<!DOCTYPE html>
<html>
<head>
<title>Hyard - 2022 Based Programming group</title>
<link rel="stylesheet" href="index.css">
<div class="header">
<a href="index">
<img src="images/logo.png" alt="head-logo" height="200" width="200" />
<div>
<nav class="mainnav">
<ul>
<li><a href="projects/selector">Projects</a></li>
<li><a href="en/about">About</a></li>
<li><a href="en/versions">Versions</a></li>
</ul>
</nav>
</div>
</div>
</head>
<body>
</body>
</html>
.header {
background-color: aqua;
width: 1440px;
margin-top: -8px;
margin-left: -8px;
margin-right: -8px;
}
.mainnav ul {
position: relative;
left: 450px;
font-size: 50px;
list-style: none;
color: gray;
text-transform: uppercase;
top: -175px;
}
.mainnav ul li {
color: gray;
text-decoration: none;
display: inline-table;
}
.mainnav ul a {
color: gray;
text-decoration: none;
}
.mainnav ul a:hover {
color: black;
}
感谢您的帮助!
So as I was making a header for my webpage the width of the webpage extended for some reason. I tried some ways of shrinking it but I was unsuccessful. Below I have linked a codepen you can just scroll and you will see just plain white right of the header that I have created.
https://codepen.io/blurfnes/pen/KKoVgby
<!DOCTYPE html>
<html>
<head>
<title>Hyard - 2022 Based Programming group</title>
<link rel="stylesheet" href="index.css">
<div class="header">
<a href="index">
<img src="images/logo.png" alt="head-logo" height="200" width="200" />
<div>
<nav class="mainnav">
<ul>
<li><a href="projects/selector">Projects</a></li>
<li><a href="en/about">About</a></li>
<li><a href="en/versions">Versions</a></li>
</ul>
</nav>
</div>
</div>
</head>
<body>
</body>
</html>
.header {
background-color: aqua;
width: 1440px;
margin-top: -8px;
margin-left: -8px;
margin-right: -8px;
}
.mainnav ul {
position: relative;
left: 450px;
font-size: 50px;
list-style: none;
color: gray;
text-transform: uppercase;
top: -175px;
}
.mainnav ul li {
color: gray;
text-decoration: none;
display: inline-table;
}
.mainnav ul a {
color: gray;
text-decoration: none;
}
.mainnav ul a:hover {
color: black;
}
Thanks for help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
1-不要将任何内容放在
&lt; head&gt;
标签中,而不是&lt; tltle&gt;
&amp;&lt; link&gt;
。 主要问题2-
&lt; div class =“ header”&gt;
很旧,应该被您拒绝。使用&lt; header&gt;
。3-
&lt; a&gt;
标签是一个链接。为什么要将&lt; nav&gt;
放入链接中?它将您的整个导航视为一个链接... Major 问题4-在CSS中,为什么您的标头宽度固定?它应该一直是
100%
。5-您的MainNAV CS必须修复...
6-而不是使用
左:450px;
使用text-align:中心
您的最终代码看起来像这样:
1- Don't put anything in the
<head>
tag except<tltle>
&<link>
. Major problem2-
<div class="header">
is very old and should be banned from you mind. use<header>
instead.3-
<a>
tag is a link. Why are you putting the<nav>
inside a link? it counts your entire nav as one link...Major problem4- in CSS, why is your header width fixed? it should be
100%
all the time.5- your mainnav CSS must be fixed...
6- instead of using
left: 450px;
usetext-align: center
Your final code will look like this:
尝试使用相对单元并擦除左侧和顶部
Try to use relative units and erase the left and top
使用此媒体查询,您要收缩哪种设备?
Use this media query, which device you want to shrink?