使用UL / LI和A的简单菜单 [英] Simple Menu using UL/LI and A

查看:117
本文介绍了使用UL / LI和A的简单菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我想制作整个< li>元素链接和可点击。这是我的代码:

Hello,

I want to make the whole <li> element a link and clickable. here is my code that I have:

展开 | 选择 | Wrap | 行号

推荐答案

''id''是一个唯一的名称仅给予一个元素。如果你必须对多个元素使用相同的样式,请使用''class''。


您正在使用:将鼠标悬停在< li>上元件。这只适用于现代浏览器,而不适用于IE6。
''id'' is a unique name which is given to one element only. If you must use the same style for multiple elements, use ''class''.

You are using :hover for the <li> element. This will only work in modern browsers and not IE6.



''id''是一个唯一的名称,只给一个元素。如果你必须对多个元素使用相同的样式,请使用''class''。


您正在使用:将鼠标悬停在< li>上元件。这只适用于现代浏览器,而不适用于IE。
''id'' is a unique name which is given to one element only. If you must use the same style for multiple elements, use ''class''.

You are using :hover for the <li> element. This will only work in modern browsers and not IE.



我知道我知道,我试图将悬停用于风格。但我想做整个< li>点击。你知道怎么做吗?

I know I know, i was trying to use the hover for style. But I want to make the whole <li> clickable. Do you know how to do this?


你不能拥有< a>在< li>之外因为< a>将被视为另一个元素,对于< ul>来说是非法的。


所以,< li>< a href .......


然后,在css中,你需要制作< a>扩展< li>的宽度。但是< a>是内联的同时< li>是块级别。所以:

ul li a {display:block; width:200px}


另一种方法是定位它:

ul li a {float:left; width:200px;}


浮动是定位它的必要条件,但我认为你可以使用任何定位方法。不要记得你是否还要定位< li>与< a>相同的宽度。
You cannot have the <a> outside the <li> because <a> will be treated as another element, which would be illegal for an <ul>.

So, <li><a href.......

Then, in css, you need to make the <a> extend the width of the <li>. But <a> is inline while <li> is block level. So:
ul li a{display:block;width:200px}

Another way to do that is position it:
ul li a{float:left;width:200px;}

The float is necessary to position it but you can use any positioning method, I think. Don''t recall if you also have to position the <li> to the same width as the <a>.


这篇关于使用UL / LI和A的简单菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆