列出项目当浏览器收缩时导航栏中的重叠站点标题

时间:2015-07-27 22:55:24

标签: html css

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

问题:为了将浏览器简单地隐藏列表项目,浏览器窗口向左缩小,反之亦然,需要更改哪些内容?

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)?感谢

1 个答案:

答案 0 :(得分:1)

当视口大小缩小时,您可以使用激活某些规则的媒体查询,就像您的情况一样。

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

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