我有一个电话号码,希望能用CSS将其变成可链接的。这个电话号码是在div里面作为背景(CSS)插入的。是否可能只使用CSS实现?
问题在于...我有很多页面,只有一个CSS页面与所有页面链接。"不使用JS"并且我不想到处更改"div"为"a"。
问题在于...我有很多页面,只有一个CSS页面与所有页面链接。"不使用JS"并且我不想到处更改"div"为"a"。
是的,与其使用div
,在这种情况下应该使用a
元素:
a.phone-number {
display: block;
width: ...;
height: ...;
background: url(...);
}
<a href="#url#" class="phone-number"></a>
div
改为 a
的背景图像,示例如下:
HTML
<a href="#">phone</a>
CSS
a.{
float:left;
width:100px;
height:200px;
text-indent:-5000px;
background: url(images/sample.jpg);
}
希望它有所帮助
这样的东西?
<div class="number"></div>
.number{ /* mention the div class name or id here */
display:inline;
cursor: pointer;
cursor: hand; /*for cross-browser support */
border-bottom: 1px solid blue; /* give your own color */
}
<a>
标签。在语义上,<a>
是正确的元素,可以为你的标记提供更多的含义。<a href="tel:+13174562564">317-456-2564</a>
这使得像iPhone和Android这样的移动设备能够将其识别为电话号码,并在触摸时启动电话呼叫。