gpt4 book ai didi

html - 导航栏缩放问题

转载 作者:太空狗 更新时间:2023-10-29 16:45:31 27 4
gpt4 key购买 nike

我有一个问题,我的导航栏似乎与 CSS 中的 .container 一起缩放。现在,我还是个新手,但我试过弄乱 CSS 中的值,但无济于事。这是 HTML 和 CSS 的代码:

* {
margin: 0px;
padding: 0px;
}
body {
font-family: verdana;
background-image: url(images/bg2.jpg);
max-width: 100%;
max-height: auto;
background-position: 0px 100px;
background-repeat: repeat-x;
background-color: black;
background-size: 100%;
}
#header {
background-color: #000000;
height: 100px;
width: 100%;
}
.container {
background-color: grey;
width: 960px;
height: auto;
margin: 0 auto;
color: rgb(200, 200, 200);
}
#logoArea {
width: 300px;
height: 100px;
background-image: url(images/logo.png);
float: left;
display: block;
}
#navArea {
height: 50%;
float: right;
}
#nav {
list-style: none;
margin-top: 5%;
}
#nav a {
color: #C8C8C8;
text-decoration: none;
width: 75px;
height: 50px;
display: table-cell;
vertical-align: middle;
padding: 0;
}
#nav li {
width: 75px;
height: 50px;
float: left;
margin-left: 30px;
background-color: #252525;
border: 2px solid silver;
border-radius: 8px;
padding: 0px;
text-align: center;
display: table-cell;
vertical-align: middle;
}
#nav li:hover {
background-color: grey;
}
.page {
background-color: rgba(19, 19, 19, 0.9);
padding: 20px;
padding-bottom: 1px;
}
p {
margin-bottom: 20px;
}

.box1 {
position: relative;
width: 300px;
height: 100px;
background-image: url(images/logo.png);
background-repeat: no-repeat;
float: left;
}

#imageLogo {
width: 960px;
height: 324px;
background-image: url(images/Triicell-logo.png);
background-repeat: no-repeat;
background-position: center;
}
<html>

<head>
<meta charset="UTF-8">
<title>Test site</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body a link="#C8C8C8" vlink="#C8C8C8" alink="#C8C8C8">
<div id="Header">
<div class="container">
<div class="box1">
<a id="logoArea"></a>
</div>
<div id="navArea">
<ul id="nav">
<li>wp_1
</li>
<li>wp_2
</li>
<li>wp_3
</li>
<li>wp_4
</li>
<li>wp_5
</li>
</ul>
</div>
</div>
</div>
<div id="mainArea">
<div class="container page">
<div id="welcome">Test site</div>
</div>
</div>
</body>

</html>

正如我所说,我是新手,所以如果我遗漏了一些非常明显的东西,如果您能为我指明正确的方向,我将不胜感激。整个上午我都在绞尽脑汁,试图思考它可能是什么。

这里有几个截图来引用我正在谈论的内容:

在缩放 .container 之前: enter image description here

缩放 .container 后: enter image description here

为了缩放它,我正在做的是将 .container 的宽度更改为 50%;。不用担心其他任何事情 - 我知道我将如何缩放其余部分,即图像等 - 但只是那个导航栏似乎跳出了位置。

但是,是的,如果有人能帮助我解决这个问题,我将非常感激。如果做不到这一点,至少给我指出正确的方向。

最佳答案

嘿,谢谢你让你的问题更容易理解,问题是如果你把容器设为 50%,那么就没有更多的空间给导航了,因为 #logoArea 宽度太大所以它会被推导航到下一行,如果你想让它工作,你应该减少#logoArea 和/或#navArea 的宽度。我希望这会有所帮助。

关于html - 导航栏缩放问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32949492/

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