[英]How to style the button with own image? How to remove the white space of the image between the <li> and <li> code?
I want to made a 3-line navigation menu. 我想做一个三行导航菜单。
This is my fiddle, http://fiddle.jshell.net/ds325/3/ 这是我的提琴, http://fiddle.jshell.net/ds325/3/
I want to style my button, the original image do not have the grey color background, I want to use my own image. 我想设置按钮样式,原始图像没有灰色背景,我想使用自己的图像。
Beside, why there are white space between my image? 在旁边,为什么我的图像之间有空白? How can I remove the white space?
如何删除空白? So that my image can connect nicely.
这样我的图像可以很好地连接。
my coding 我的编码
<script src="http://code.jquery.com/jquery-1.7.1.js"></script>
<button class="menu" ><img src="http://i.stack.imgur.com/EkwMp.png" width="40" height="40" /></button>
<div id="navbar" style="display:none;">
<nav>
<ul>
<li>
<div id="wrapper">
<img src="http://www.weatherclipart.net/free_weather_clipart/umbrellas_page_border_graphic_0515-0908-2220-2617_SMU.jpg" width="35" height="52" class="hover" />
<p class="text"><a href="#">Home</a></p>
</div>
</li>
<li>
<div id="wrapper">
<img src="http://www.weatherclipart.net/free_weather_clipart/umbrellas_page_border_graphic_0515-0908-2220-2617_SMU.jpg" width="35" height="52" class="hover" />
<p class="text"><a href="#">About</a></p>
</div>
</li>
<li>
<div id="wrapper">
<img src="http://www.weatherclipart.net/free_weather_clipart/umbrellas_page_border_graphic_0515-0908-2220-2617_SMU.jpg" width="35" height="52" class="hover" />
<p class="text"><a href="#">Contact</a></p>
</div>
</li>
</ul>
</nav>
</div>
CSS CSS
#wrapper .text {
position:relative;
bottom:50px;
left:50px;
visibility:hidden;
}
#wrapper:hover .text {
visibility:visible;
}
ul {
list-style:none;
}
Javascript 使用Javascript
$('.menu').click(function() {
$('#navbar').toggle('slow');
});
If can, please give me a demo, so that it will be more easy for me to understand, thanks. 如果可以的话,请给我一个演示,以便我更容易理解,谢谢。
this is exactly what I want, thanks for helping http://fiddle.jshell.net/ds325/5/ 这正是我想要的,感谢您的帮助http://fiddle.jshell.net/ds325/5/
Have you tried to use the list-style-image
on your li elements ? 您是否尝试过在li元素上使用
list-style-image
? Like this : 像这样 :
ul li {
list-style-image: url('path/of/image/file');
}
(Sorry but i'm not sure to understand the question if my answer is not what you're waiting for). (对不起,如果我的答案不是您在等待的内容,我不确定这个问题)。
you need to use anchor instead of button like following 您需要使用锚点而不是按钮,如下所示
<a class="menu" ><img src="http://i.stack.imgur.com/EkwMp.png" width="40" height="40" /></a>
Here is the working demo 这是工作演示
http://fiddle.jshell.net/ds325/3/ http://fiddle.jshell.net/ds325/3/
and if you talking about the space between the home link and the image you can simple update your css as 如果您谈论的是首页链接和图片之间的空间,则可以简单地将CSS更新为
#wrapper .text {
position:relative;
bottom: 42px;
left: 34px;
visibility:hidden;
}
Updated 更新
Add this to your css 将此添加到您的CSS
#navbar div {
height: 53px;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.