Reputation: 1979
I have a label
that contains a Input
Radio
with a background image.
As you can see here
I need the "Ja" and "Nej" to be like 5-10pix to the left, but I just can't seem to find a solution. Can someone help me here ?
HTML:
<label id="labelradio1" for="Radio1">Ja
<input id="Radio1" type="radio" value="yes"></label>
<label id="labelradio2" for="Radio2">Nej
<input id="Radio2" type="radio" value="no"></label>
CSS:
#txtradiocall input[type='radio']{
position:absolute;
margin: -99999px;
}
#txtradiocall label{
display: inline-block;
cursor: pointer;
width: 15px;
height: 15px;
margin: 4px;
}
#txtradiocall #labelradio1 {
background: url('http://www.xxxx.com/images/images/thumb_up_green-v2.png');
background-repeat:no-repeat;
cursor: pointer;
width: 35px;
height: 22px;
}
#txtradiocall #labelradio2 {
background: url('http://www.xxxx.com/images/images/thumb_down-red-v2.png');
background-repeat:no-repeat;
cursor: pointer;
width: 35px;
height: 22px;
}
Upvotes: 0
Views: 1116
Reputation: 253486
I'd suggest:
#txtradiocall #labelradio1 {
background-image: url('http://placekitten.com/35/22');
}
#txtradiocall #labelradio2 {
background-image: url('http://placekitten.com/35/22');
}
#txtradiocall label {
padding: 0 40px 0 0;
cursor: pointer;
width: 35px;
height: 22px;
background-position: 100% 50%;
background-repeat: no-repeat;
}
The above specifies the background-image
property, rather than the shorthand, because with the shorthand the id
-based selectors overrides the later declarations for background-repeat
and background-position
(since the shorthand defines all properties, -color
, -repeat
and -position
).
Also, specify all shared properties in one place, which makes it easier to keep properties consistent and more easily maintainable.
Upvotes: 1