【发布时间】:2011-05-26 03:48:53
【问题描述】:
让链接同时具有文本和图像的最佳解决方案是什么,并且该解决方案仍将在 XHTML 1.0 STRICT 下通过 w3c 验证?并且没有 JavaScript。
【问题讨论】:
标签: xhtml tags hyperlink image
让链接同时具有文本和图像的最佳解决方案是什么,并且该解决方案仍将在 XHTML 1.0 STRICT 下通过 w3c 验证?并且没有 JavaScript。
【问题讨论】:
标签: xhtml tags hyperlink image
使用 CSS,一开始就不需要 javascript。
<a href="#" class="image">Hello</a>
<style>
.image {
padding-left: 20px; // width of image
background: url(image.jpg) no-repeat scroll left center;
height: 20px; // height of image
line-height: 20px; //height of image
// other rules that you need
}
</style>
【讨论】:
我会将链接(锚点)包裹在一个 div 周围,然后 give the div a background image w CSS。在 DIV 中添加一个包含文本的跨度并在跨度上设置“边距”样式以对齐文本以适应口味。
基本上测试 TEXT 看起来会叠加在图像上。
希望这会有所帮助。
【讨论】:
您是否尝试过阅读http://htmldog.com/?这通常显示如何使用基本的 HTML
<a href="link.html">
TEXT HERE
<img src="imageurl.jpg" width="100" height="100" alt="TEXT HERE FOR ALT" />
</a>
【讨论】: