r/csshelp • u/hero0fwar • Feb 25 '14
Resolved Hover Flair
I have hit a brick wall. Cannot get this to work for the life of me. It works just fine with a single image, I am messing it up with the sprite somehow
.flair:after{font-size:0}
.flair-001{
font-size: 0!important;
position:relative;
}
.flair-001:after {
display:none;
}
.flair-001:hover{
font-size: x-small!important;
word-spacing:0em;
letter-spacing:0em;
}
.flair-001:before{
content:url(%%sprite-final%%);
background-position: 0 -82px; width: 20px;
}
.flair-001:hover:before{
content:url(%%sprite-final%%);
margin-right:2px;
background-position: 0 -82px; width: 20px;
}1
u/hero0fwar Feb 25 '14
Actually just changed it a bit. Closer, but not there yet
.flair {
background: url(%%sprite-final%%) no-repeat scroll -99999px transparent;
height: 20px;
vertical-align: middle;
border: 0px;
}
.flair:after{font-size:0}
.flair-001{background-position: 0 -82px; width: 20px}
.flair-001{font-size: 0!important;position:relative;}
.flair-001:after{display:none;}
.flair-001:hover{font-size: small!important;word-spacing:0em;letter-spacing:0em; margin-right:22px }1
1
u/gavin19 Feb 25 '14
What exactly do you want to happen when the flair is hovered? Does the flair have text or is just the image?
If the flair is just an image with the text hidden until hover
.flair { background: transparent url(%%sprite-final%%) no-repeat -9999px; height: 20px; vertical-align: middle; border: 0; } .flair-001 { background-position: 0 -82px; min-width: 20px; text-indent: -9999em; } .flair-001:hover { text-indent: 22px; }1
u/hero0fwar Feb 25 '14
Yep, that was exactly what I needed, I actually just figured it out as you sent this. Thanks for your time
1
u/hero0fwar Feb 25 '14
Hey, can you check something out for me: http://redd.it/1yssxq
When it is a larger icon the flair is getting kind of messed up, here is the final css I was using
.flair { max-width: 100%; background: transparent url(%%sprite-final%%) no-repeat -9999px; height: 20px; vertical-align: middle; border: 0; font-weight:bold; } .flair-002 {background-position: 0 0px; min-width: 20px; text-indent: -9999em;} .flair-003 {background-position: 0 -21px; min-width: 20px; text-indent: -9999em;} .flair-004 {background-position: 0 -62px; min-width: 20px; text-indent: -9999em;} .flair-007 {background-position: 0 -42px; min-width: 20px; text-indent: -9999em;} .flair-001 {background-position: 0 -82px; min-width: 20px; text-indent: -9999em;} .flair-008 {background-position: 0 -103px; min-width: 20px; text-indent: -9999em;} .flair-006 {background-position: 0 -124px; min-width: 20px; text-indent: -9999em;} .flair-005 {background-position: 0 -143px; min-width: 20px; text-indent: -9999em;} .flair-001-002 {background-position: 0 -163px; min-width: 41px; text-indent: -9999em;} .flair-001-003 {background-position: 0 -183px; min-width: 41px; text-indent: -9999em;} .flair-001-004 {background-position: 0 -203px; min-width: 41px; text-indent: -9999em;} .flair-001-005 {background-position: 0 -223px; min-width: 41px; text-indent: -9999em;} .flair-001-006 {background-position: 0 -243px; min-width: 41px; text-indent: -9999em;} .flair-001-007 {background-position: 0 -263px; min-width: 41px; text-indent: -9999em;} .flair-001-008 {background-position: 0 -282px; min-width: 41px; text-indent: -9999em;} .flair-001-002-004 {background-position: 0 -303px; width: 62px; text-indent: -9999em;} .flair:hover { text-indent: 22px; vertical-align: middle;} .flair-001-002:hover,.flair-001-003:hover,.flair-001-004:hover,.flair-001-005:hover,.flair-001-006:hover,.flair-001-007:hover,.flair-001-008:hover { text-indent: 42px; vertical-align: middle;} .flair-001-002-004:hover{ text-indent: 63px; vertical-align: middle;}3
u/gavin19 Feb 25 '14
.flair-001-002-004 {background-position: 0 -303px; width: 62px; text-indent: -9999em;}Should be
min-width.1
1
u/hero0fwar Feb 26 '14
Hey, if you are around today, could you help me out quick
http://www.reddit.com/r/thelastofus/comments/1mmcjx/its_a_thought_spoilers/cfp5w05
that is just a test comment to show the word wrapping.
.flair{border:0;background-color:inherit;font-weight:bold;padding:3px;color:#EF9F16;min-width:200px}So that is what I am using for the flair, I set it up to allow users to insert extra text after their name, but after 200px it will wrap. is there a way to make it unlimited? some kind of float? and if it does have to wrap match the text-indent?
1
u/gavin19 Feb 26 '14
In the global
.flairblock you've specified amin-widthof 200px. Is there any reason why this isn't 26px, ie the width of the image?Also, in the example, the templates class has a fixed width of 26px set. This is being overridden by the min-width property since it takes priority, but it needn't be there.
tl;dr change the
width: 26px;from the template class tomin-widthand remove themin-width: 200pxfrom the.flairblock.1
u/hero0fwar Feb 26 '14
the reason I was using the default as 200 was because one of the flairs is huge.
I just adjusted what you said
.flair{border:0;background-color:inherit;font-weight:bold;padding:3px;color:#EF9F16;height:25px;} .flair-ellie {background-image: url(%%ellie%%);background-repeat:no-repeat!important;text-indent:25px;min-width:26px}But won't that just wrap the text after 26px?
1
u/gavin19 Feb 26 '14
the reason I was using the default as 200 was because one of the flairs is huge.
Then put a larger min-width value into the CSS for that template. If the majority of the flairs are 26px then you can save repetition and put that into the global flair block. If you need a different value for any of the classes then just put one into their block and it'll override it.
But won't that just wrap the text after 26px?
No, that's the reason for min-width. It only forces a minimum, nothing else. Don't use
widthanywhere in the flairs.
2
u/lazenbooby Feb 25 '14
So I was about to say...
Then I realised you're a mod of 297 subs. How the hell do you cope?!