gpt4 book ai didi

html - CSS - 转换功能不适用于链接?

转载 作者:搜寻专家 更新时间:2023-10-31 22:19:23 26 4
gpt4 key购买 nike

当 href 的扩展名为 .pdf 时,我确实喜欢这样做; .doc; .ppt; .xls 然后它会在它前面添加相应的文件图片。然后,当我将鼠标悬停在链接上时,我尝试使链接变小,但我什么也没做!我是不是做错了什么?

enter image description here

代码:

ul{
list-style-type: none;
}
ul a{
text-decoration:none;
padding-left: 20px;
background-repeat: no-repeat;
}
ul a:hover{
text-decoration:underline;
color:#666;
-moz-transform: scale(0.9);
-webkit-transform: scale(0.9);
-ms-transform: scale(0.9);
transform: scale(0.9);
}
a[href$=".pdf"]{
background-image:url(http://i.stack.imgur.com/zJlYq.gif);
}
a[href$=".doc"]{
background-image:url(http://i.stack.imgur.com/z2lbW.gif);
}
a[href$=".ppt"]{
background-image:url(http://i.stack.imgur.com/Tk5Vv.gif);
}
a[href$=".xls"]{
background-image:url(http://i.stack.imgur.com/sOr7E.gif);
}
<ul>
<li><a href="/one.pdf">pdf</a></li>
<li><a href="/two.doc">doc</a></li>
<li><a href="/three.ppt">ppt</a></li>
<li><a href="/four.xls">xls</a></li>
</ul>

最佳答案

你应该使用 display: inline-block对于 <a>标记(或 display: block ),因为 <a>display: inline默认情况下,但是 transformable element不能与 display: inline 一起使用:

Transformable element — an element whose layout is governed by the CSS box model which is either a block-level or atomic inline-level element, or ...

Inline-block — this value causes an element to generate an inline-level block container. The inside of an inline-block is formatted as a block box, and the element itself is formatted as an atomic inline-level box.

ul {
list-style-type: none;
}

ul a {
text-decoration: none;
padding-left: 20px;
background-repeat: no-repeat;
display: inline-block;
}

ul a:hover {
text-decoration: underline;
color: #666;
-webkit-transform: scale(0.9);
-moz-transform: scale(0.9);
-ms-transform: scale(0.9);
transform: scale(0.9);
}

a[href $= '.pdf'] {
background-image: url(http://i.stack.imgur.com/zJlYq.gif);
}

a[href $= '.doc'] {
background-image: url(http://i.stack.imgur.com/z2lbW.gif);
}

a[href $= '.ppt'] {
background-image: url(http://i.stack.imgur.com/Tk5Vv.gif);
}

a[href $= '.xls'] {
background-image: url(http://i.stack.imgur.com/sOr7E.gif);
}
<ul>
<li><a href="/one.pdf">pdf</a></li>
<li><a href="/two.doc">doc</a></li>
<li><a href="/three.ppt">ppt</a></li>
<li><a href="/four.xls">xls</a></li>
</ul>

关于html - CSS - 转换功能不适用于链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34710090/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com