r/csshelp • • Nov 04 '13

Announcment Bar

I'm working on /r/totaldrama/ and wondering how to do something like /r/Disney_Infinity/ did with the link to the "this week in infinity" post

6 Upvotes

17 comments sorted by

1

u/ImThatAwesomeDude Nov 05 '13

I was curious to find this out too so I went looking in inspect element and in the subreddit's stylesheet and found out that it's simpler than it may seem. All you need to do is add this code to your subreddit's stylesheet:

.side .md h4:nth-of-type(1){list-style-type:none!important;position:absolute;font-size:12pt;display:block;top:140px;left:5px;margin:0;background-color:#f6f7f8!important;color:black;text-align:left;border-radius:2px;border:1px solid #dbdbdb;width:auto;padding:7px 10px 7px 10px;white-space:nowrap;overflow:hidden}

And make the first h4 in your sidebar the text that you want to appear at the top of the subreddit. Make adjustments as needed. If it doesn't work, I'm always willing to help.

Edit: Dear lord that code block looks ugly in this subreddit.

2

u/Bongo9911 Nov 05 '13

Thanks!

1

u/ImThatAwesomeDude Nov 05 '13

Anytime! You've done some good css work so far on your subreddit and I might have to subscribe, seeing as though I watched total drama back in the day.

1

u/Bongo9911 Nov 05 '13

I have the best birthday present from Total Drama, having the 100th episode air tomorrow which is my bday :)

1

u/ImThatAwesomeDude Nov 05 '13

Oh, well, lucky you! I assume you've seen every episode?

1

u/Bongo9911 Nov 05 '13

Yeah :) just last month I started at the first episode and watched every episode all the way to the latest episode

1

u/ImThatAwesomeDude Nov 05 '13

Oh really? You never saw any episodes before just last month? How did you hear about total drama?

1

u/Bongo9911 Nov 05 '13

I did, I've been watching since the beginning, I just had a TD marathon

1

u/ImThatAwesomeDude Nov 05 '13

Ah, thought so. Cool.

1

u/Bongo9911 Nov 05 '13

Does h4 just mean the first line? Because I put the CSS in the stylesheet then typed "test" in the first line on my sidebar in subreddit settings then hit enter twice afterwards

1

u/ImThatAwesomeDude Nov 05 '13 edited Nov 05 '13

No no, in CSS, h4 is a fourth-level header. On reddit, you can use it by prefacing a line with four hash/pound symbols, like so:

####This is a fourth-level header.

Which appears normally as:

This is a fourth-level header.

Hope this helps.

Edit: Do you know how to change the div's position on the page, and colours, and font weight, and stuff? Just checking, because you're probably going to want to, if you haven't already, since that block of CSS code was made specifically for the Disney_Infinity subreddit.

Edit 2: It looks like you got it working!

1

u/Bongo9911 Nov 05 '13

The answer to the question is, I only know how to get hex color numbers.

1

u/ImThatAwesomeDude Nov 05 '13 edited Nov 05 '13

I've got a few CSS tips for you. First, you'll probably want to add this to your stylesheet: .content{margin-top:45px} just like /r/Disney_Infinity did because otherwise the announcement bar will overlap the subreddit content. Also, you probably want to raise the announcement bar, your subreddit header banner is shorter than /r/Disney_Infinity's so you don't need it as low. 130px instead of 140px would look perfect.

1

u/ImThatAwesomeDude Nov 05 '13

It looks like you lowered the content, but you haven't yet raised the announcement bar. You should do that soon, because it looks off right now. Also, it will still look off unless there's enough "content" in the announcement bar, so it makes a bar that stretches across the entire top of the page. In the end it should look like this, which looks pretty fine if you ask me.

Edit: So you added actual content to the announcement bar, but don't forget to raise it by 10px!

3

u/XibalbaN7 Nov 04 '13

I'd be interested in finding out how to do this also. Would be great to have some form of News Ticker I could place breaking news/Topic of the week etc.

2

u/ImThatAwesomeDude Nov 05 '13

I figured out how to do it, if you were curious. Check out my other comment in this thread. Don't miss the part about adding .content{margin-top:45px} as well.

2

u/XibalbaN7 Nov 05 '13

Thank you! Messaging you too ;)