将一个列表项目包装在一个锚点中听起来很合理吗? [英] Is it sound to wrap a list item in an anchor?

查看:183
本文介绍了将一个列表项目包装在一个锚点中听起来很合理吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组图像,每个图像都有自己的链接。我希望图像位于列表中(< ul>< li> .. etc),并让每个项目具有不同的 background- image



我会遇到类似这样的问题吗?

 < UL> 
< a href =#>< li class =1>< / li>< / a>
< a href =#>< li class =2>< / li>< / a>
< a href =#>< li class =3>< / li>< / a>
< a href =#>< li class =4>< / li>< / a>
< a href =#>< li class =5>< / li>< / a>
< a href =#>< li class =6>< / li>< / a>
< / ul>


解决方案

p>

 < ul> 
< li class =1>< a href =#>< / a>< / li>
< li class =2>< a href =#>< / a>< / li>
< li class =3>< a href =#>< / a>< / li>
< / ul>

然后您可以添加 background-image a li



然而,您可以将 a s设置为 display:block 并赋予它们相同的 height width li 。这样背景图片就会显示出来,整个 li 都可以点击。

I have a group of images which each have their own links. I want the images to be in a list (<ul><li> .. etc) and have each item have a different background-image.

Would I run into any issues with something like this?

<ul>
<a href="#"><li class="1"></li></a>
<a href="#"><li class="2"></li></a>
<a href="#"><li class="3"></li></a>
<a href="#"><li class="4"></li></a>
<a href="#"><li class="5"></li></a>
<a href="#"><li class="6"></li></a>
</ul>

解决方案

You would do better to write it like this

<ul>
<li class="1"><a href="#"></a></li>
<li class="2"><a href="#"></a></li>
<li class="3"><a href="#"></a></li>
</ul>

Then you could add the background-image to either the a or the li.

However, you would style the as as display:block and give them the same height and width of the li. That way the background-image would show and the entire li would be clickable.

这篇关于将一个列表项目包装在一个锚点中听起来很合理吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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