gpt4 book ai didi

html - 浏览器缩小时列表项与导航栏中的站点标题重叠

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

当我的浏览器全屏显示时,一切看起来都很好。但是,当浏览器缩小(缩小到屏幕尺寸的一半)时,导航栏中的链接(列表项)会与导航栏另一侧的 div(网站标题)重叠。

问题:需要更改什么才能将其固定为浏览器窗口向左收缩时浏览器简单地隐藏列表项的位置,反之亦然?

HTML代码:

<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Hyperdog Productions</title>
<link href="css/stylesheet.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="wrapper">
<div id="navigation_bar">
<p><a href="index.html" class="logo" id="home">Hyperdog Productions</a></p>
<ul class="navbar_list">
<li class="nav_list" id="about"><a class="nav_link" "href="about.html">About</a></li>
<li class="nav_list" id="short_films"><a class="nav_link" href="films.html">Short Films</a></li>
<li class="nav_list" id="cast/crew"><a class="nav_link" href="other.html">Cast/Crew</a></li>
<li class="nav_list" id="contact_us"><a class="nav_link" href="contact_us.html">Contact Us</a></li>
<li class="nav_list" id="other"><a class="nav_link" href="other.html">Other</a></li>
</ul>
</div> <!--End of NAV-->
<main id="container">
<div id="container_wrapper">
</div>
<div id="footer">
</div>
</main> <!--End of Main-->
<footer id="copyright">
</footer>
</div> <!--End of WRAPPER-->
</body>
</html>

如果下面有很多错误,我也不会感到惊讶。对不起!这是我的 CSS:

@font-face {
font-family: "Lato-Regular";
src: url("../fonts/Lato-Regular/Lato-Regular.ttf");
src: url("../fonts/Lato-Regular/Lato-Regular.woff");
}

@font-face {
font-family: "PT-Sans";
src: url("../fonts/PT-Sans/PTS55F.ttf");
src: url("../fonts/PT-Sans/PTS55F.woff");
}

* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
/* Margin: 0; */
}

html, body {
margin: 0;
padding: 0;
width: 100%;
height: 1500px;
overflow-x: none;
font-size: 0;
}

body {
font-size: 62.5%;
}

.wrapper {
height: 1500px;
}

#navigation_bar {
width: 100%;
height: 100px;
background-color: #1d1d1d;
}

main {
height: 1300px;
}

#container_wrapper {
width: 100%;
height: 865px;
background-color: green;
}

#footer {
width: 100%;
height: 435px;
background-color: blue;
}

#copyright {
width: 100%;
height: 100px;
background-color: black;
}

.nav_link:link {
margin: 0;
padding: 10px;
text-decoration: none;
text-align: center;
font-family: "Lato-Regular", "PT-Sans", "Calibri Light", sans-serif;
font-size: 1.2em;
line-height: 3.7em !important;
text-transform: uppercase;
color: #ffffff;
}

.nav_link:hover {
color: grey;
}

.navbar_list {
float: right;
position: absolute;
float: right;
right: 15%;
top: 25px;
text-align: center;
}

.navbar_list li {
float: left;
list-style-type: none;
list-style: none;
padding: 9px 12px;
margin: 0;
font-size: 10px;
display: inline;
}

.logo {
font-family: Verdana, sans-serif;
font-size: 24px;
color: white;
margin: 0;
padding: 9px 12px;
color: red;
float: left;
left: 15%;
position: absolute;
text-transform: uppercase;
letter-spacing: 5px;
color: grey;
top: 25px;
text-align: center;
}

此外,如何在导航栏中垂直居中列表项和站点标题 (Hyperdog Productions)?谢谢

最佳答案

当视口(viewport)大小缩小到一半时,您可以使用激活某些规则的媒体查询。

示例如果您的视口(viewport)大小缩小到 600px,那么这些规则适用于您情况下的相应元素,列表项保持隐藏

@media (max-width: 600px) {
.navbar_list {
display: none;
}
}

关于html - 浏览器缩小时列表项与导航栏中的站点标题重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31664687/

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