xhtml li以整个li作为链接(xhtml li with entire li as link)
我目前有以下代码:
<ul id="menu-list"> <a href="index.php"> <li>Home</li> </a> <li><a href="about.php">About</a></li> </ul>列表中的第一个元素允许将整个li块作为链接单击,但不遵循xhtml标准。 第二个遵循标准,但只有李的文字是一个链接。 是否有符合标准的获取第一个功能的方法?
I currently have the following code:
<ul id="menu-list"> <a href="index.php"> <li>Home</li> </a> <li><a href="about.php">About</a></li> </ul>The first element in the list allows the entire li block to be clicked as a link but does not follow xhtml standards. The second follows standards but only the text in the li is a link. Is there a standards compliant way of getting the first functionality?
最满意答案
如果你定义css作为内联块,你可以给它100%的宽度和高度,并获得你正在寻找的功能。
<style> #menu-list li a { display:inline-block; height: 100%; width: 100%; } </style> <ul id="menu-list"> <li><a href="about.php">About</a></li> </ul>If you define css for the anchor to make it inline-block you can give it 100% width and height of the li and get the functionality you are looking for.
<style> #menu-list li a { display:inline-block; height: 100%; width: 100%; } </style> <ul id="menu-list"> <li><a href="about.php">About</a></li> </ul>更多推荐
发布评论