I did like so when a href's extension is .pdf; .doc; .ppt; .xls then it'll add corresponding file picture in front of it. Then I tried making a link go smaller when I hover over it but I doesn't do anything! Am I doing something wrong or what?
Code:
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>
You should use display: inline-block
for <a>
tag (or display: block
), because <a>
has display: inline
by default, but transformable element can't be with 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With