我创建了一个导航菜单,用于重新设计一个印刷公司的网站。一切都运行良好,但我无法找到更改浏览器大小时导航收缩的原因。我之前创建了这些菜单,而且我从未遇到过缩小的问题。
以下是演示https://jsfiddle.net/dshojaei/vbcztkdy/3/embedded/result/
#nav_wrap {
text-align: center;
background-color:#343232;
border-top:1px solid black;
height:54px;
}
/* Reset */
.nav,
.nav a,
.nav ul,
.nav li,
.nav div,
.nav form,
.nav input {
margin: 0;
padding: 0;
border: none;
outline: none;
}
.nav a { text-decoration: none; }
.nav li { list-style: none; }
/* Menu Container */
.nav {
display: inline-block;
position: relative;
cursor: default;
z-index: 500;
text-align:left;
}
/* Menu List */
.nav > li {
display:block;
float: left;
}
/* Menu Links */
.nav > li > a {
position: relative;
display: block;
z-index: 510;
height: 54px;
padding: 0 20px;
line-height: 54px;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 13px;
color: #fcfcfc;
text-shadow: 0 0 1px rgba(0,0,0,.35);
background: #343232;
border-left:none;
border-right:none;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-o-transition: all .3s ease;
-ms-transition: all .3s ease;
transition: all .3s ease;
}
.businesscards:hover > a {
background:#009ad6;
}
.flyers:hover > a{
background:#c60077;
}
.cards:hover > a {
background:#cec41e;
}
.banner:hover > a {
background:#000000;
}
.dvd:hover > a {
background:#3c3c3c;
}
.stationary:hover > a {
background:#7b7b7b;
}
.labels:hover > a {
background:#afafaf;
}
.catalogs:hover > a {
background:#d7d7d7;
}
.nav > li:first-child > a {
border-radius: 0px 0 0 0px;
border-left: none;
}
/* Menu Dropdown */
.nav > li > div {
position: absolute;
display: block;
width: 100%;
top: 55px;
left: 0;
opacity: 0;
visibility: hidden;
overflow: hidden;
border-right:1px solid black;
border-left:1px solid black;
border-bottom:1px solid black;
background: #ffffff;
border-radius: 0 0 3px 3px;
-webkit-transition: all .3s ease .15s;
-moz-transition: all .3s ease .15s;
-o-transition: all .3s ease .15s;
-ms-transition: all .3s ease .15s;
transition: all .3s ease .15s;
}
.nav > li:hover > div {
opacity: 1;
visibility: visible;
overflow: visible;
}
/* Menu Content Styles */
.nav .nav-column {
float: left;
width: 20%;
padding: 2.5%;
}
.nav .nav-column h3 {
margin: 20px 0 10px 0;
line-height: 18px;
display:inline;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 14px;
color: #372f2b;
text-transform: uppercase;
}
/*.nav .nav-column img {
display:inline;
width:20%;
height: 20%;
}
*/
.nav img:nth-of-type(1) {
margin-top:30px;
margin-left:20px;
float:left;
width:5%;
height:5%;
}
.nav img:nth-of-type(2) {
margin-top:30px;
margin-left:20px;
float:left;
width:5%;
height:5%;
}
#brochure {
margin-top:30px;
margin-left:20px;
float:left;
width:3%;
height:3%
}
.nav .nav-column h3.orange { color: #ff722b; }
.nav .nav-column li a {
display: block;
line-height: 26px;
font-family: Helvetica, Arial, sans-serif;
font-weight: bold;
font-size: 13px;
color: #888888;
}
.nav .nav-column li a:hover { color: #666666; }
答案 0 :(得分:1)
您可以将列表项的代码更改为以下内容:
.nav > li {
display: inline-block;
}
并且,将以下声明添加到列表规则集:
.nav {
display: inline-block;
position: relative;
cursor: default;
z-index: 500;
text-align:left;
white-space: nowrap;
}
为了正确显示,HTML中的列表项应该彼此相邻,否则你会看到空格:
<ul><li></li><li></li></ul>
答案 1 :(得分:1)
修正宽度。
.nav { display: inline-block; position: relative; cursor: default; z-index: 500; text-align: left; width: 1190px; }