r/csshelp • • Mar 01 '20

How do I make one of those "hover over" rules?

example

I wanted to do some CSS for my subreddit, /r/12n. I am wanting to know how I do those "hover over" rules like on /r/blursedimages and /r/fffffffuuuuuuuuuuuu.

7 Upvotes

1 comment sorted by

1

u/permagrinfalcon Mar 01 '20

If you're planning on adding more headers to your sidebar, I'd change your rules to h3 (#Rule 1 vs ###Rule 1) or something you won't be using as the below css will affect all #Headers.

.side .usertext-body h1,
.side .usertext-body ul {
    margin: 0;
}

.side .usertext-body h1 {
    margin-top: 10px;
    border: 1px solid #ccc;
    border-bottom: none;
    padding: 5px 10px;
    font-size: 14px;
}

.side .usertext-body h1 + ul {
    height: 0;
    border: 1px solid #ccc;
    border-top: none;
    overflow: hidden;
    list-style: none;
    padding: 0 10px;
}

.side .usertext-body h1:hover + ul,
.side .usertext-body h1 + ul:hover{
    height: auto;
    padding-bottom: 5px;
}