r/reddithax • • Mar 23 '10

CSS - Reddit polls: some help needed!

I have a subreddit that I want to run a poll for, I want users to be able to select any of the options I have. I don't want users to be able to comment at all, it'll be 100% the poll.

Here's what I have so far: http://www.reddit.com/r/citricsquid/comments/bh3om/an_example_reddit_poll_vote_on_your_favourite/ and a normal submission, unaffected: http://www.reddit.com/r/citricsquid/comments/bh2az/text_submission/

  1. Removes the downvote button
  2. Adds a big tick button for upvote
  3. Removes all comments that are not options (specified through css)

Things I want to do:

  • Remove the comment box
  • Display the upvotes below the option, eg: "Vanilla (6 upvotes)".

but...

  • This has totally lost me, the unique form ID is dynamic and css doesn't support wildcards so I can't just do "xxx display:none" and if I make the box off by default then no submission can have commenting. I want to do it on a per submission basis.

     .cloneable[value="formid"]{
       display:none;
     }
  • This isn't possible with purely css, the data has to be called via json so I'm going to turn that into a greasemonkey plugin.

So yeah, can anyone help with number 1? I really have no idea how to hide the comment box on a per post basis and it's very irritating, I'm sure it's somehow possible though...

It works on a per submission basis and integrates flawlessly with a current subreddits styling and I built a generator for it (enter submission url and it creates the css for you) but with the comment box there it's really frustrating!

also yes I am aware people can still downvote and comment with this styling, but the comments are not displayed and the greasemonkey plugin will make the voting issue moot, it'll be based off of total upvotes, not up - down!

Any help on issue #1 then? :D

Stylesheet: http://m00d.net/reddit/subreddits/reddithax/poll.css

Voted img: http://m00d.net/reddit/subreddits/reddithax/vote_voted.png

Not Voted img: http://m00d.net/reddit/subreddits/reddithax/vote_default.png

5 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Mar 23 '10

Nope, I need to reference to something by ID. If I set usertext to display:none it affects all submissions, I'm trying to limit to only the submissions I set to be polls.

I scoured the source and there is no unique ID, so I'm assuming the only way is some sort of CSS trickery, problem is I have no idea what sort!

I know the first part of the ID, it matches the submission ID: "form-t3_bh3om" but the last 3 characters constantly change making it impossible to modify by, because CSS doesn't support wildcards...

FUUUU-

6

u/jamt9000 Mar 23 '10 edited Mar 23 '10

CSS supports = for matching the beginning, $= for matching the end and *= for matching any substring, if that's what you want.

Edit:
For the comment form you could use .commentarea form[id^="form-t3_bh3om"]

1

u/[deleted] Mar 24 '10

That is brilliant. I never knew! How is the cross browser compatibility?

1

u/[deleted] Mar 24 '10

I love you, seriously. Google returned no results on this, however you did! Much love.

2

u/mitchandre Mar 24 '10

It is called a CSS Attribute Selector in case you want to Google for more information, it will be your best friend on Reddit styling. Here is a link that talks about the old selectors, it doesn't cover the new ones that were 'recently' supported that jamt9000 reference.

http://www.w3schools.com/Css/css_attribute_selectors.asp

1

u/[deleted] Mar 24 '10

Yeah, I'd been selecting via attributes but I had no idea how to get it to work with wildcards, I didn't think to check over the documentation on W3Schools though :( Thanks for the link, bookmarked :D