我是HTML / CSS场景的新手,我正在尝试创建一个内联菜单,而在最后一个,而不是一个,我想要一个图像:<li><img src=""/></li>
,它有一个下拉菜单,便于导航移动设备(我的目标是响应式菜单)。
我可能在CSS上迷失了......我感谢任何帮助或指导
菜单预览/示例: https://www.dropbox.com/s/debmbo40qpknawb/example.jpg
检查小提琴: http://jsfiddle.net/csNCe/
HTML
<header>
<div class="container clearfix"><a href="#" class="logo"><img src="img/logo.png" alt="We Made You - Future Together" class="logo" width="65" height="21"/></a>
<span>Stylish</span>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">About</a></li>
<li><img src="img/menu.png" id="android" width="50" height="39"/></li>
<!--<ul>
<li><a href="#">Home</a></li></li>
<li><a href="#">Portfolio</a></li></li>
<li><a href="#">Services</a></li></li>
<li><a href="#">About</a></li></li>
<li><a href="#">Contacts</a></li></li>
</ul></li>-->
</ul>
</nav>
</div>
</header>
CSS
body{
width: 100%;
background-image: url(../img/bg.jpg) no-repeat;
height: 100%;
}
.container{
width: 1000px;
margin: 0 auto;
}
header{
background-color: #1c1c1c;
width: 100%;
height: 40px;
margin: 0;
padding: 0;
display: block;
text-align: center;
}
header .logo{
float: left;
}
header span{
float: left;
color: white;
font-size: 12px;
font-weight: bold;
margin-top: 12px;
margin-left: 20px;
}
header nav{
float: right;
}
header .logo{
margin: 0;
padding: 0;
margin-top: 4px;
}
header nav ul{
margin: 0;
padding: 0;
margin-right: 20px;
line-height: 36px;
}
header nav li{
width: 100px;
display: inline-block;
font-size: 12px;
text-transform: uppercase;
}
header nav li{
width: 100px;
display: inline-block;
font-size: 12px;
text-transform: uppercase;
}
header nav ul li a{
font-weight: bold;
text-decoration: none;
color: white;
}
header nav ul li:hover{
color: white;
text-decoration: none;
background-color: #303030;
}
header nav ul li a:hover{
color: white;
}
答案 0 :(得分:1)
HTML
<header>
<img src="http://www.socialtalent.co/images/blog-content/so-logo.png"/>
<div id="menu">
<div id="v"> <a href="#">home</a></div>
<div id="v"> <a href="#">portafolio</a></div>
<div id="v"> <a href="#">about</a></div>
<div class="ui-icon">
<div id="sub">
<a href="#">submenu</a>
<a href="#">submenu2</a>
<a href="#">submenu3</a>
</div>
</div>
</div>
</header>
CSS
header{
width: 100%;
height: 59px;
background: green;
}
img{
width: 200px;
height: 60px;
}
.ui-icon{
position: absolute;
background-image: url(http://cdn-img.easyicon.net/png/10747/1074745.gif);
background-repeat: no-repeat;
background-size: 30px 30px;
background-position: 2px 8px;
width: 35px;
height: 45px;
right: 40px;
top: 14px;
}
#menu{
background: #222;
float:right;
width: 350px;
height: 59px;
margin: 0 25px 0 0;}
#v{
color:#fff;
display:inline-block;
margin: 18px 0 0 0;
}
a{
font-size:14px;
display:block;
text-decoration:none;
font-family:Helvetica, Arial, sans-serif;
font-weight:normal;
color: white;
padding:0 25px 10px 25px;}
a:hover{
color:#444;
text-decoration:none;}
.ui-icon:hover #sub{
display:block;
}
#sub:after{
content: '';
position: absolute;
width: 60px;
height: 20px;
background-color: transparent;
top:-20px;
right: 0;
}
#sub:before {
right: 16px;
content: '';
position: absolute;
margin: -18px 0 0 0;
border-top: none;
border-right: 8px solid transparent;
border-left: 8px solid transparent;
border-bottom: 8px solid #FFFFFF;
}
#sub{
width:100px;
margin: 53px 70px 0 -70px;
padding: 10px;
background:#ccc;
display:none;
position:absolute;
z-index:2;}
答案 1 :(得分:0)
试试这个
<div class="container clearfix"><a href="#" class="logo"><img src="img/logo.png" alt="We Made You - Future Together" class="logo" width="65" height="21"/></a>
<span>Stylish</span>
<ul class="mainmenu">
<li><a href="#">Home</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">About</a></li>
<li><img src="https://mail.google.com/mail/u/0/photos/img/photos/private/AIbEiAIAAABECODY0r_3mprz2AEiC3ZjYXJkX3Bob3RvKigyMDFiNjk1ODlmNzVhN2E2NDRiOWY1NjkzOWVmZTUzMDUxNjUyOWVkMAHZmRD1ZZjPufQO9TfzylPzSSTCFg" id="android" width="50" height="39"/></li>
<ul class="submenu">
<li><a href="#">Home</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contacts</a></li>
</ul>
</ul>
</div>
</header>
添加以下css到您的css文件
.mainmenu {
width:400px;text-align:left;display:block;position:relative;top:50px;
}
.submenu {
display:none;
}
.mainmenu:hover .submenu{
display:block;
}
如果这不是你想要的,请告诉我。