【发布时间】:2015-06-15 20:21:55
【问题描述】:
在响应式网站上,我想在小屏幕上显示垂直菜单,在大屏幕上显示水平菜单。 目前,以下 HTML 和 CSS 代码不会在较小的屏幕上显示垂直菜单。任何人都可以修改/改进此代码吗?提前致谢。
#menu {
width: 100%;
min-height: 40px;
position: relative;
background-color: rgb(52, 85, 154);
}
#menu a {
display: inline-block;
padding: 10px 4% 0px 4%;
font: 400 16px/32px 'Courier', sans-serif;
min-height: 40px;
color:white;
text-decoration: none;
font-weight:bold;
transition: .5s;
}
#menu a:hover {
color: red;
background-color: blue;
}
@media screen and (max-width:640px) {
#menu {
max-width: 100%;
}
}
@media screen and (max-width:775px) {
#menu a {
max-width: 100%;
padding: 0px 5px 0px 5px;
float: none;
text-align: center;
}
}
@media screen and (max-width:980px) {
#menu {
max-width: 100%;
}
}
<body>
<nav id="menu"> <a href="index.html">Home</a> <a href="aboutus.html">About</a> <a href="services.html">Services</a> <a href="http://srjtax.blogspot.com/" rel="external" target="_blank">Blog</a> <a href="taxlinks.html">Links</a> <a href="faq.html">FAQ</a> <a href="contact.html">Contact</a>
</nav>
</body>
【问题讨论】: