Html 将图像放在锚标签上

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42368962/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 14:24:08  来源:igfitidea点击:

put an image on an anchor tag

htmlcss

提问by Suraj

I have an ullike below which has anchor tags.

我有一个ul喜欢下面的锚标签。

<ul class="nav-link-bottom">
        <li><a class="active"  href="login.html">Existing user</a></li>
        <li><a href="signup.html" style = "background-color:#000">new user</a></li>
</ul>

I want to place an image on the second anchor tag. Not sure how I can do that.

我想在第二个锚标签上放置一个图像。不知道我怎么能做到这一点。

Here's the fiddle. And the imageI want to put on the left anchor same position as the caret you see.

这是小提琴。和我想放在左锚上的图像与您看到的插入符号相同的位置。

回答by Oke Tega

Don't really understand you question but if you want the imgto serve as link, you could do

不太明白你的问题,但如果你想img充当link,你可以做

<a href="page.html"><img src="img.png"></a>

And then give the anchor tagwhat ever heightor width

然后给anchor tag什么曾经heightwidth

回答by Michael Benjamin

<li><a href=""><img src="" alt=""></a></li>