HTML is what makes up your page. It has elements like p
for paragrpahs, a
for anchors (links), div
for dividing things into arbitrary parts. and others. Each element can have attributes like class names. The elements are arranged in nested manner to accomplish your layout.
The CSS has rules to apply to the HTML. For it to take effect, the selector has to match the HTML. Rules can apply to multiple parts of the HTML, and the HTML can be styled by multiple rules. When there are multiple rules for the same property, the most specific selector one is applied. If two are the same selector, the last one written is applied. (that’s the Cascade — the C in CSS)
To make your new box style, you should use a new class name, so it won’t interfere with the theme’s styling, and you can put it where you want. Otherwise your styles will have to overcome different things on different pages, and you have to add a lot of existing names to apply it on different pages.
So the CSS would be like
.myown-box { background color: white; border: 1px solid gray; padding: 0.5em;
width: 30%; display: inline-block; vertical-align: top; margin-right: 0.6%; }
@media (max-width: 720px) { /* adjust the number for your theme */
.myown-box { width: 100%; margin-right: 0; }
}
And you put the text myown-box
into the Class input for your block.
In CSS selectors, classes start with a dot, IDs start with a #, and a space indicates nesting.
When you try to put the post-content
class on other things, it mislabels it and probably gets styles you don’t want. Besides, you were having trouble because most of Masonry is done by Javascript, and it probably wasn’t loaded on that page.