是否有可能使超链接看起来像是带有文本的按钮?带图像和文本的HTML超链接
我们可以超链接按钮,代码:
<a href="..."> <img src="button.png" width="100" height="50" alt="Some text"></img> </a>
,但我还需要在按钮的中心文本。
谢谢。
是否有可能使超链接看起来像是带有文本的按钮?带图像和文本的HTML超链接
我们可以超链接按钮,代码:
<a href="..."> <img src="button.png" width="100" height="50" alt="Some text"></img> </a>
,但我还需要在按钮的中心文本。
谢谢。
这是通过设置按钮作为背景可能:
<a href="..." style="text-align:center; background: url('button.png'); width: 100px; height: 50px;">Your text</a>
但我会尽量避免与背景图像按钮(除非他们是一个奇怪的形状)。相反,我会尝试使用CSS3。
我建议,没有确切知道你想要什么,并假设以下加价:
<a href="#"><img src="path/to/image.png" /><span>Some text</span></a>
a {
position: relative;
display: inline-block;
}
a span {
position: absolute;
top: 50%;
left: 50%;
margin-top: -1em;
margin-left: -50%;
width: 100%;
height: 2em;
color: #f90;
background-color: rgba(0,0,0,0.5);
}
您可以使用一些UI框架,如bootstrap或Flat ui。
<a href="#" class="btn btn-primary"> Click Me</a>