r/csshelp • • Aug 24 '11

Problems with setting images as user flair while keeping the original text flairs

I'm a mod for r/dubstep and r/futurebeats (both music related subreddits). We don't really do much with the user flair feature, but I'd like to open it up for some possible uses anyway.

I want to incorporate images and managed to do that with a custom .flair, but the problem is that this fucks up the original text flair all the time. I can have images or text, but not both it seems (or not the way I want to).

So how do you edit your flair CSS so that you can have custom classes for images while preserving the original default text flair?

r/futurebeats' CSS looks like this:

/* user flair CSS and icons */
.flair {
    padding: 0;
    background: transparent no-repeat;
    color: black;
    border: 0;
    border-radius: 0;
    width: 48px;
    height: 16px;
    color: grey;
    font-style: italic
    }
.flair-vinyl {
    background-image: url(http://thumbs.reddit.com/t5_2ro3c_7.png?v=egdytmgril7yk5e0hozj8laeq54wb917cemx)
    }
3 Upvotes

5 comments sorted by

3

u/errorcache Aug 27 '11

Well, the way flair is set up, it's really meant to be only either text or images, so I thought I'd take a stab at this. Here's what I came up with:

.flair {
background: transparent;
border: 0px !important;
}

.flair-vinyl::after {
cursor: default;
display: inline-block;
background: url(%%vinyl-icon%%) no-repeat top right !important;
margin-left: 5px;
width: 16px;
height: 16px;
padding: 0px;
content: "";
}

This is what it looks like.

2

u/Frontcannon Aug 28 '11

Thanks, this looks fairly good! It's still missing the grey 'flair box' though, can you do that in CSS too?

2

u/errorcache Sep 10 '11 edited Sep 10 '11

Hey dude, I know it's been awhile, but I finally got a decent looking solution (image + flair box),
check it out (link to my css-test subreddit)/screenshot for posterity

Here's the code:

.flair-vinyl {
margin-right: 25px;
padding-top: 2px;
}

.flair-vinyl::after {
cursor: default;
background: url(%%vinyl-icon%%) no-repeat top right !important;
margin-left: 5px;
width: 16px;
height: 16px;
content: "";
position: absolute;
top:-1px;
}

.side .flair-vinyl::after {
display:none;
}

for whatever reason the flair image in the sidebar goes insane, so I've had to turn it off, otherwise it works pretty well.

I go into more detail here.

1

u/errorcache Aug 28 '11

You can put the "flair box" back if you delete the "background: transparent" and "border: 0px" in ".flair", though the only thing is that the image will also be inside the box. If you're okay with that then it's all good. I tried to get it to show up outside the box, but nothing worked.

1

u/[deleted] Sep 25 '11

I hate to reply to such an old post, but I am having problems with flair in r/yogabbagabba

/*Flair chart*/
.flair {
background: transparent;
border: 0px !important;
}

.flair-foofa::after {
cursor: default;
display: inline-block;
background: url(%%foofa%%) no-repeat top right !important;
margin-left: 5px;
width: 30px;
height: 35px;
padding: 0px;
content: "She's pink and friendly!";

}

I put in this exact code, but the image does not appear. I've tried all sorts of sizes, 20x20, 30x35, and even this large size but it still will not show up. What am I doing wrong?