我正在尝试用面包屑预告片的图像替换主页链接文本。鼠标光标仍然是指针,但图像不会显示。我正在使用this breadcrumb trailer
我怎么能让它工作呢jsfiddle
<li itemprop="itemListElement" itemscope itemtype="" class="trail-item trail-begin">
<a href="#" rel="home" itemprop="item"><span itemprop="name">Home</span></a>
<meta itemprop="position" content="1" />
</li>
CSS:
li.trail-begin {
display: inline-block;
font-size: 0;
color: 000;
height: 25px;
position: static;
text-align: center;
width: 30px;
line-height: 25px;
margin: 0;
}
li.trail-begin a {
background-image: url("https://1.bp.blogspot.com/-T3iC1fWjXIM/XqVHr8gv4GI/AAAAAAAAAGE/k5EviLmoDwkttKB9sUgjVbCSTlinrOqlACLcBGAsYHQ/s1600/1-2-home-png-image-thumb.png");
background-position:left;
background-repeat:no-repeat;
background-size: 25px;
}
最合适的回答,由SO网友:simongcc 整理而成
你的问题更像是一个CSS问题。默认情况下,定位点a显示为内联。所以它没有高度和宽度,除非里面有有限尺寸的文本、图像等。要使其工作,只需添加display:block;
以使其扩展以匹配父容器。
li.trail-begin {
display: inline-block;
font-size: 0;
color: 000;
height: 25px;
position: static;
text-align: center;
width: 30px;
line-height: 25px;
margin: 0;
}
li.trail-begin a {
background-image: url("https://1.bp.blogspot.com/-T3iC1fWjXIM/XqVHr8gv4GI/AAAAAAAAAGE/k5EviLmoDwkttKB9sUgjVbCSTlinrOqlACLcBGAsYHQ/s1600/1-2-home-png-image-thumb.png");
background-position:left;
background-repeat:no-repeat;
background-size: 25px;
display: block; /* <-------- */
}