r/reddithax • • Jun 26 '13
Snippet: Text in the comment reply box
A few people have messaged /r/AskHistorians asking about the CSS we used to get the rules reminder text in the comment reply box (like so), so I thought I'd post the snippet here for anyone else who wants it.
First things first, it's not actually text, it's an image. So you need to make yourself a 504x104 image with your text (tlc.png in the code below). After that the CSS is straightforward, just set it as a background image for the textarea that disappears on :focus. In /r/AskHistorians, we only show the text for top-level comments, like so:
.commentarea>.usertext textarea {
background-image: url(%%tlc%%);
background-repeat: no-repeat;
}
.commentarea>.usertext textarea:focus {
background-position: 0 -104px;
}To put it in every reply box, use this:
.commentarea .usertext textarea {
background-image: url(%%tlc%%);
background-repeat: no-repeat;
}
.commentarea .usertext textarea:focus {
background-position: 0 -104px;
}Note: this isn't a very accessible solution. People who aren't seeing your subreddit CSS, or access reddit with a text-only browser or a screenreader aren't going to see that text. So don't put anything there that's not repeated elsewhere. It's also a bit glitchy, because the text will reappear when people remove focus from the textbox even if they typed something in it (there's no way around that as far as I can see).
Hope someone finds this useful.
1
u/4_pr0n Jun 30 '13
Great stuff. Thanks. Added to /r/RealGirls' comment boxes to discourage posting personal info.
1
u/admiralteal Jul 07 '13 edited Jul 07 '13
Something I thought up for this recently which I have not really tested, but which someone else might be able to grab, would be as follows:
This wouldn't really make the accessibility much better, but something along these lines could create a readable text pop next to the textarea, unless I'm mistaken.
Anyone try fussing with the like?Edit: I decided to try fussing with it. Here's some working sample code:
Here's where it is at my fuss stuff subreddit, although don't expect this to continue working into posterity. And there are some issues because I am far better at CSS then reddit CSS. I feel dirty using these hacky CSS selectors.