gpt4 book ai didi

html - 带有响应式下拉菜单的内联菜单

转载 作者:太空宇宙 更新时间:2023-11-04 13:44:57 25 4
gpt4 key购买 nike

我是 HTML/CSS 场景的新手,我正在尝试创建一个内联菜单,最后,我想要一个图像,而不是一个 :<li><img src=""/></li> ,它有一个下拉菜单,以便更轻松地在移动设备上导航(我的目标是响应式菜单)。

我可能对 CSS 很迷茫...感谢任何帮助或指导

菜单预览/示例: https://www.dropbox.com/s/debmbo40qpknawb/example.jpg

检查 fiddle : 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;
}

最佳答案

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;}

关于html - 带有响应式下拉菜单的内联菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22585799/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com