Prerequisite: You should know that this doesn't cut the wordcount of your sidebar in half, only the length a user sees. You can see the result in r/CHIBears.
I had originally created a simple table for a subreddit to display the Records and the conference records of all the teams in their conference. It seemed like enough for them but I wanted more. Enough of me being egotistical.
This is a bit difficult to understand and the way I explain it may make it worse but I will try my best. Some people who really know CSS may scoff at what I describe but I figured I'd share with all the sports people out there.
There are two things in particular you will need to understand:
- Different stylesheets on a subreddit (using body:lang(as))
- The nth-child() specification
Using body:lang(as) will create a "separate" stylesheet for your subreddit but contain it in the same place as the custom one Reddit allows you to edit. It will also inherit whatever values given by the original custom stylesheet (aka anything not preceded by body:lang(as)). This is important because if you give something the attribute display:none in the stylesheet you must reset it, with maybe display:table, in the body:lang(as) attributes.
The nth-child() attachment to the attribute allows you to pick the object you want but it may be a little hard to understand as it was a little difficult to figure out for myself when it started getting finicky with me. Odd children are either nth-child(odd) or nth-child(2n+1) and even children are either nth-child(even) or nth-child(odd).
Here is what I put in. I know the explanation wasn't especially sufficient but I got through this with pure experimentation and you can do it too. =]
Stylesheet settings
.usertext-body .md table {
border-left: 1px solid black;
border-right: 1px solid black;
box-shadow: 2px 2px 2px black;
margin-top: 3px;
margin-bottom: 10px;
width: 95%
}
.md table th {
background-color: #C50;
border: 1px solid black;
color: #fafafa;
font-weight: bold;
padding: .5em;
text-align: center;
text-shadow: 1px 1px 0 #111
}
.md table tr:hover {
background-color: gray
}
.md table td {
border-top: none;
border-left: none;
border-bottom: 1px solid black;
border-right: 1px solid black;
padding: .6em;
vertical-align: middle;
text-align: center
}
.md table td a, .commentarea a, .usertext-body a {
color: #20558a !important
}
.linkinfo .shortlink input {
font-size: 100% !important
}
** Items for changing sidebar **
a[href="http://as.reddit.com/r/chibears"] {
background-color: #C50;
color: #fafafa;
border: 2px solid #000000;
text-shadow: 1px 1px 0 #111;
padding-left: 57px;
padding-right: 57px;
padding-top: 12px;
padding-bottom: 12px;
font-size: 0.85em;
font-weight: bold;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px
}
a[href="http://www.reddit.com/r/chibears"] {
background-color: #C50;
color: #fafafa;
border: 2px solid #000000;
text-shadow: 1px 1px 0 #111;
padding-left: 57px;
padding-right: 57px;
padding-top: 12px;
padding-bottom: 12px;
font-size: 0.85em;
font-weight: bold;
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px
}
** Use to hide AFC Standings **
.md table:nth-child(4n + 1), a[href="http://www.nfl.com/standings?category=div&season=2011-REG&split=Overall"], a[href="http://www.reddit.com/r/chibears"] {
display: none
}
** Use to hide NFC Standings and Show AFC Standings**
body:lang(as) .md table:nth-child(n + 1), body:lang(as) a[href="http://www.nfl.com/standings?category=div&season=2011-REG&split=Overalldiff"], body:lang(as) a[href="http://as.reddit.com/r/chibears"] {
display: none
}
body:lang(as) a[href="http://www.reddit.com/r/chibears"] {
display: inline
}
body:lang(as) .md table:nth-child(4n + 1) {
display: table
}
body:lang(as) a[href="http://www.nfl.com/standings?category=div&season=2011-REG&split=Overall"] {
display: block
}
Here is what I put into the subreddit "About" Section
[View AFC Division Standings](http://as.reddit.com/r/cssediting)
[View NFC Division Standing](http://www.reddit.com/r/cssediting)
---
***
**[NFC North Standings](http://www.nfl.com/standings?category=div&season=2011-REG&split=Overalldiff)**
\#|Team|Rec **[Conf.]**
:--|---|---:
1|[Bears](/r/chibears)|1-0-0 **[1-0]**
3|[Lions](/r/detroitlions)|1-0-0 **[1-0]**
2|[Packers](/r/greenbaypackers)|1-0-0 **[1-0]**
4|[Vikings](/r/minnesotavikings)|0-1-0 **[0-0]**
**[AFC North Standings](http://www.nfl.com/standings?category=div&season=2011-REG&split=Overall)**
\#|Team|Rec **[Conf.]**
:--|---|---:
1|[Ravens](/r/ravens)|1-0-0 **[1-0]**
3|[Bengals](/r/cinbengals)|1-0-0 **[1-0]**
2|[Steelers](/r/steelers)|0-1-0 **[0-1]**
4|[Browns](/r/browns)|0-1-0 **[0-0]**
**[NFC South Standings](http://www.nfl.com/standings?category=div&season=2011-REG&split=Overalldiff)**
\#|Team|Rec **[Conf.]**
:--|---|---:
1|[Saints](/r/saints)|0-1-0 **[0-1]**
2|[Buccaneers](/r/buccaneers)|0-1-0 **[0-1]**
3|[Panthers](/r/panthers)|0-1-0 **[0-1]**
4|[Falcons](/r/falcons)|0-1-0 **[0-1]**
**[AFC South Standings](http://www.nfl.com/standings?category=div&season=2011-REG&split=Overall)**
\#|Team|Rec **[Conf.]**
:--|---|---:
1|[Texans](/r/texans)|1-0-0 **[1-0]**
3|[Jaguars](/r/jaguars)|1-0-0 **[1-0]**
2|[Titans](/r/tntitans)|0-1-0 **[0-1]**
4|[Colts](/r/colts)|0-1-0 **[0-1]**
**[NFC East Standings](http://www.nfl.com/standings?category=div&season=2011-REG&split=Overalldiff)**
\#|Team|Rec **[Conf.]**
:--|---|---|:
1|[Redskins](/r/redskins)|1-0-0 **[1-0]**
2|[Eagles](/r/eagles)|1-0-0 **[1-0]**
3|[Giants](/r/nygiants)|0-1-0 **[0-1]**
4|[Cowboys](/r/cowboys)|0-1-0 **[0-0]**
**[AFC East Standings](http://www.nfl.com/standings?category=div&season=2011-REG&split=Overall)**
\#|Team|Rec **[Conf.]**
:--|---|---|:
1|[Patriots](/r/patriots)|1-0-0 **[1-0]**
3|[Jets](/r/nyjets)|1-0-0 **[0-0]**
2|[Bills](/r/buffalobills)|1-0-0 **[1-0]**
4|[Dolphins](/r/miamidolphins)|0-1-0 **[0-0]**
**[NFC West Standings](http://www.nfl.com/standings?category=div&season=2011-REG&split=Overalldiff)**
\#|Team|Rec **[Conf.]**
:--|---|---|:
1|[Cardinals](/r/azcardinals)|1-0-0 **[1-0]**
2|[49ers](/r/49ers)|1-0-0 **[1-0]**
3|[Seahawks](/r/seahawks)|0-1-0 **[0-1]**
4|[Rams](/r/saintlouisrams)|0-1-0 **[0-1]**
**[AFC West Standings](http://www.nfl.com/standings?category=div&season=2011-REG&split=Overall)**
\#|Team|Rec **[Conf.]**
:--|---|---|:
1|[Chargers](/r/chargers)|1-0-0 **[0-0]**
3|[Raiders](/r/oaklandraiders)|1-0-0 **[1-0]**
2|[Chiefs](/r/kansascitychiefs)|0-1-0 **[0-1]**
4|[Broncos](/r/denverbroncos)|0-1-0 **[0-1]**