本文介绍了两个图像链接之间的下划线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在div中有以下HTML代码:

I have the following HTML code inside a div:

<a href="http://www.mysql.com">
<img src="images/php-power-micro2.png" alt="Image not available" title="PHP" border="0"/>
</a>
<a href="http://www.php.net"> 
<img src="images/mysql-power.jpg" alt="Image not available" border="0" title="MySQL"/>
</a>

这会导致以下输出与它们之间有

Which results in the following output with an underscore!? between them:

如果我只使用一个图像链接,下划线就会消失。

If I use only one image-link the underscore disappears.

为什么会发生这种情况,如何摆脱下划线? >

Why is this happening and how can I get rid of the underscore?

推荐答案

下划线是一个或多个带下划线的空格字符。修复是删除可能作为 a 元素中的空格(例如换行符)的任何内容。换行符和其他空格在标签(< > )之间可以:

The underscore is one or more underlined space characters. The fix is to remove anything that might be taken as a space inside an a element, such as a line break. A line break and other whitespaceinside a tag (between < and >) is OK, though:

<a href="http://www.mysql.com"><img src="images/php-power-micro2.png" 
  alt="PHP powered" border="0" title="PHP" /></a>
<a href="http://www.php.net"><img src="images/mysql-power.jpg"
  alt="MySQL powered" border="0" title="MySQL"/ ></a>

这意味着 a 元素,浏览器通常将其视为空格。在这种情况下,这可能没有关系,因为空间在元素之外,因此不会加下划线;它只是造成一点间距。但为了使图像更清晰地分开,请考虑在第二个 a 元素上添加 padding-left

This means that there is still a line break between the a elements, and browsers generally treat it as a space. In this case, this probably does not matter, since the space is outside a elements and thus won’t be underlined; it just causes a little spacing. But to make the images more clearly separate, consider adding padding-left on the second a element.

这篇关于两个图像链接之间的下划线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-17 00:00