我有这个链接,我嵌入到一个图标,我想在图标本身下面添加一个描述文字。
示例:电子邮件图标,在其下面我会有“电子邮件”
这是我目前的链接,我想添加标题“电子邮件”
<a title="Email" class="icon-envelope" data-bind="attr: { 'href': 'mailto:' + Email() }"></a>
我如何使用css和html的组合来实现这一目标?
答案 0 :(得分:0)
HTML
<a title="Email" class="icon-envelope" data-bind="attr: { 'href': 'mailto:' + Email() }">Email</a>
CSS
.icon-envelope {
display:block;
width:100px;
height:100px;
padding:110px 0 0 0;
background: url(http://placekitten.com/100/100) no-repeat;
text-align:center;
}
的jsfiddle
答案 1 :(得分:0)
[详细] DEMO: http://jsfiddle.net/FCP9k/
a[title] {
position: relative;
margin-bottom: 1em;
width: 100px;
height: 100px;
display: block;
background-image: url('http://placekitten.com/100/100'); /* Default image */
border: 1px solid red;
margin-bottom: 1em;
}
a[title="Email"] {
background-image: url('http://placekitten.com/200/200'); /* Email icon */
}
a[title="SomethingElse"] {
background-image: url('http://placekitten.com/300/300'); /* A different icon */
}
a[title]:after {
content: attr(title);
position: absolute;
top: 100px;
display: block;
text-align: center;
width: 100%;
left: 0;
}
答案 2 :(得分:0)
<强> HTML 强>
<a title="Email" class="icon-envelope" data-bind="attr: { 'href': 'mailto:' + Email() }">Email</a>
<强> CSS 强>
.icon-envelope {
padding-top:100px; /*height of bg image*/
display:block;
}
答案 3 :(得分:-4)
<a href="foo">
<img src="bar" alt="">
<br>
Email
</a>
或
<a href="foo">
<img src="bar" alt="">
Email
</a>
带
a img { display: block; }