The problem is very simple:
<div id="main-content">
<ul>
<li>
<div class="post-row">
<div class="post-footer">
This is the Footer
<div class="footer-buttons">
<ul>
<li>Edit</li>
<li>Reply</li>
</ul>
</div>
</div>
</div>
</li>
</ul>
</div>
And now main content:
#main-content ul {
margin:0;
padding:0;
}
#main-content ul li {
display:block;
list-style:none;
}
And last, footer-buttons:
.footer-buttons {
float:right;
}
.footer-buttons ul {
margin:0;
padding:0;
}
.footer-buttons ul li {
display: inline;
}
The problem is that the list in .footer-buttons
is displayed as block. And in fact when I checked DOM the display: inline
is overrided by the #main-content
.
From what I know understrand this shouldn't happen. Or am I wrong and id elements will always override child classes?
The element>element selector is used to select elements with a specific parent. Note: Elements that are not directly a child of the specified parent, are not selected.
The trick is to give the sibling the same size and position as the parent and to style the sibling instead of the parent. This will look like the parent is styled!
There is currently no way to select the parent of an element in CSS, at least not a way that works across all browsers.
You have 2 selectors: #main-content ul li
and .footer-buttons ul li
. First of them uses id and the second uses class, that's why the first one is used as more descriptive. Use:
#main-content .footer-buttons ul li { display: inline; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With