1

I have an a tag with right padding of 20px. How can I put just the right part of this image as background inside padding?

enter image description here

CSS rule for now:

.mali_oglas_kontrola a {padding-right: 20px }
.mali_oglas_kontrola a:first-of-type {background: url('../img/resursi/mgl_kontrola.png') no-repeat -17px 0;background-position: right top}
.mali_oglas_kontrola a:first-of-type:hover {background: url('../img/resursi/mgl_kontrola.png') no-repeat -17px -20px; background-position: right}
4

1 に答える 1

3

それはいけません..

aアイコンを保持するタグ内に別の要素を挿入します。

<a href="...">whatever <i></i></a>

そして使う

.mali_oglas_kontrola a i{
    display:inline-block;
    width:..;/*exact width of icon*/
    height:..;/*exact height of icon*/
    background: url('../img/resursi/mgl_kontrola.png') no-repeat right top;
}
.mali_oglas_kontrola a:hover i{
    background-position: right -20px;
}
于 2012-06-21T13:48:37.003 に答える