将一个列表项目包装在一个锚点中听起来很合理吗? [英] Is it sound to wrap a list item in an anchor?
问题描述
我有一组图像,每个图像都有自己的链接。我希望图像位于列表中(< 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 a
s 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屋!