Css 将图像放置在垂直导航栏旁边
这是我的代码,我想做的是,我必须把图像放在垂直导航栏旁边,而不干扰列表的顺序。我尝试了很多次,但都没有成功,这是我的代码 HTML部分Css 将图像放置在垂直导航栏旁边,css,html,Css,Html,这是我的代码,我想做的是,我必须把图像放在垂直导航栏旁边,而不干扰列表的顺序。我尝试了很多次,但都没有成功,这是我的代码 HTML部分 <ul class="navbar"> <li><a href="#">» Computers</a> </li> <li><a href="#">» Storage Media</a></li> <li><a href="#" &
<ul class="navbar">
<li><a href="#">» Computers</a>
</li>
<li><a href="#">» Storage Media</a></li>
<li><a href="#" >» Networking Solutions</a></li>
<li><a href="#/">» Security Solutions</a></li>
<li><a href="#">» Office Automations</a></li>
<li><a href="#">» Gadgets</a></li>
<li><a href="#">» Projectors and Display Screens</a></li>
<li><a href="#">» Softwares</a></li>
<li class="lastitem"><a href="#">» Customized Solutions</a></li>
</ul>
取出
位置:绝对
并添加显示:块;浮动:向左
至。导航栏
并添加带有float:left的图像代码>
sexypanelright.gif
:我想这不是一个用于演示解决方案的维基百科重新排序:D。你可能想用sexypanelright.gif
更新它,他将被迫使用绝对定位的图像,当然不是最好的方法。你的第一个建议更好,你所需要做的就是将图像元素放在HTML列表上方,等等!但据我所知,柴坦尼亚希望将图像放在垂直导航栏的右侧
。起初我认为OP可能希望在导航栏的左侧有一个图像,但我开始怀疑他们希望在每个列表项旁边有图标。是的,我想将图像放在垂直导航栏的右侧,即在用户的右侧。如果在列表之前或之后插入img标记,则图像将被列表本身隐藏。
.navbar{
list-style-type: none;
margin: 0;
padding: 10 0px;
width: 280px; /* width of menu */
position:absolute;
}
.navbar li{
border-bottom: 1px solid white; /* white border beneath each menu item */
}
.navbar li a{
background: #333 url(media/sexypanelright.gif) no-repeat right top; /*color of menu by default*/
font: bold 13px "Lucida Grande", "Trebuchet MS", Verdana;
display: block;
color: white;
width: auto;
padding: 5px 0; /* Vertical (top/bottom) padding for each menu link */
text-indent: 8px;
text-decoration: none;
border-bottom: 1px solid black;
}
.navbar li a:visited, .navbar li a:active{
color: white;
}
.navbar li a:hover{
background-color: black; /*color of menu onMouseover*/
color: white;
border-bottom: 1px solid black;
}
.navbar ul li:hover{
background-color: black;
color: #ff0066;
display:block;
width:200px;
height:200px;
opacity:0.75;
}
.navbar ul li:hover{
padding:5px;
margin:0px;
background-color:#666666;
border-width:1px;
border-style:solid;
border-color:#333333;
}
.navbar li {
border-bottom: 1px solid white;
margin-left: 40%;
}
.navbar {
list-style-type: none;
margin: 0px;
width: 100%;
position: absolute;
}