所以我正在建立一个投资组合网站,我刚刚完成了主导航 - 但我很难获得一个可用的移动版本,我的所有尝试都没有正常工作......
基本上我正在尝试创建它,以便在手机上查看时,页面顶部只有单词MENU,当您单击MENU菜单时,导航会在下拉列表中打开。
有人可以就如何在移动版上实现这一效果给我一些指导吗?我将把我当前的代码放在下面以及JSFiddle。
HTML:
<div id='cssmenu'>
<ul>
<li><a href='index.html'>HOME</a></li>
<li class='has-sub'><a href='#'>TWENTY FIFTEEN</a>
<ul>
<li><a href='painting-2015.html'>PAINTING</a></li>
<li><a href='#'>SCULPTURE</a></li>
</ul>
</li>
<li><a href='#'>ABOUT</a></li>
<li><a href='#'>CONTACT</a></li>
</ul>
</div>
CSS:
#cssmenu {
float: left;
clear: left;
}
#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a {
margin: 0;
padding: 0;
border: 0;
list-style: none;
line-height: 1;
display: block;
position: relative;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#cssmenu {
width: 220px;
font-family: Open Sans, sans-serif;
color: #000;
}
#cssmenu ul ul {
display: none;
}
#cssmenu > ul > li.active > ul {
display: block;
}
.align-right {
float: right;
}
#cssmenu > ul > li > a {
padding: 16px 22px;
cursor: pointer;
z-index: 2;
font-size: 12px;
text-decoration: none;
color: #000;
background: #fff;
-webkit-transition: color .2s ease;
-o-transition: color .2s ease;
transition: color .2s ease;
}
#cssmenu > ul > li > a:hover {
color: #ccc;
}
#cssmenu ul > li.has-sub > a:after {
position: absolute;
right: 26px;
top: 19px;
z-index: 5;
display: block;
height: 10px;
width: 2px;
background: #000;
content: "";
-webkit-transition: all 0.1s ease-out;
-moz-transition: all 0.1s ease-out;
-ms-transition: all 0.1s ease-out;
-o-transition: all 0.1s ease-out;
transition: all 0.1s ease-out;
}
#cssmenu ul > li.has-sub > a:before {
position: absolute;
right: 22px;
top: 23px;
display: block;
width: 10px;
height: 2px;
background: #000;
content: "";
-webkit-transition: all 0.1s ease-out;
-moz-transition: all 0.1s ease-out;
-ms-transition: all 0.1s ease-out;
-o-transition: all 0.1s ease-out;
transition: all 0.1s ease-out;
}
#cssmenu ul > li.has-sub.open > a:after,
#cssmenu ul > li.has-sub.open > a:before {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
#cssmenu ul ul li a {
padding: 14px 22px;
cursor: pointer;
z-index: 2;
font-size: 12px;
text-decoration: none;
color: #000;
background: #fff;
-webkit-transition: color .2s ease;
-o-transition: color .2s ease;
transition: color .2s ease;
}
#cssmenu ul ul ul li a {
padding-left: 32px;
}
#cssmenu ul ul li a:hover {
color: #ccc;
}
#cssmenu ul ul > li.has-sub > a:after {
top: 16px;
right: 26px;
background: #000;
}
#cssmenu ul ul > li.has-sub > a:before {
top: 20px;
background: #000;
}
小提琴 - http://jsfiddle.net/7fshu82L/
非常感谢任何帮助!
答案 0 :(得分:1)
你可以考虑像这样包装'cssmenu':
<div id="menu">
<div id="cssmenu">
//your code
</div>
隐藏“#menu”,然后处理所需的动画以显示它!
这是一个有效的demo