Grandmaster Container CSS
Restructuring the Codex
We are currently moving articles around and changing the general structure of the Codex. Please come back later if you get lost!- Use [section]s if you want to add a special effect to a line of text or an inline image or icon.
- Use [container]s if you want to add a special effect surrounding a block of text or element. In this guide we mostly use containers for the examples.
Understanding Bootstrap
The easiest way to use containers is to target Bootstrap classes. Bootstrap is the CSS Framework on which World Anvil is built on. The framework takes care of many intricacies to ensure the website looks good and remains responsive on as many devices and browsers as possible. This means you can use the classes used by the framework to implement your own layouts. Not everything bootstrap offers can be used because some components requires special attributes to be set. This is currently only possible with custom templates.The Bootstrap Grid
The core of the bootstrap layout system is the grid. This grid is made up of up to twelve columns and can be utilized to display content next to each other. The columns come with so-called breakpoints for screen sizes defined. This allows you a good layout for both mobile and desktop screens without too much tinkering. Example Columns 2/3 + 1/3 - Click to Expand[row] [container:col-md-8] [/container] [container:col-md-4] [/container] [/row]
Sidebar Panels
The sidebar panel which is used in most articles can be easily duplicated. Just use the following containers and get the same effect anywhere on World Anvil:[container:panel panel-default card] [container:panel-body card-body] Your Content [/container] [/container]
Adding Unique Effects to Specific Elements
With the use of containers it is possible to make sure certain CSS is only applied to a single element or a group of elements. For example if you wish to have a special type of tables that should have a different look from your other tables you can just wrap those tables with a container and then adjust your CSS to target only that. You can use this trick for any element you embed into an article! Table Example - Click to Expand[container:your-class] [table] ... [/table] [/container]
.user-css .your-class .table { ... }
Adding Icons
With the help of containers or sections it is possible to add icons from Fontawesome & RPGawesome into your content. World Anvil has the Pro version of Fontawesome which means that you can use all of their icons and not just the free ones. Fontawesome Icon Example - Click to Expand[section:fas fa-2x fa-book] [/section]
[section:ra ra-dragon] [/section]
Additional Layout Boxes
It is very easy to create additional layout boxes like the [aloud] or [quote] BBCodes. You can find the BBCode and CSS for the boxes used on the Codex. From there you should be able to customize your own containers as you need. These examples also show how you can reuse CSS rules effectively.
.box-grey {
background: #b1b1b166;
border: 1px solid #616161;
}
.box-contain {
margin: 5px;
border-radius: 0px 15px 0px 15px;
padding: 10px;
}
[container:box-contain box-grey] Your content [/container]
.box-orange {
background: #ffa5004f;
border: 1px solid #ffa500;
}
.box-contain {
margin: 5px;
border-radius: 0px 15px 0px 15px;
padding: 10px;
}
[container:box-contain box-orange] Your content [/container]
Box with Icon
The below example creates a box with an icon in the upper right corner.
CSS - Click to Expand
.user-css .box-special {
position: relative;
padding: 10px 10px 10px 50px;
border: purple solid 2px;
background: mediumpurple;
border-radius: 20px;
}
.user-css .box-special .corner-icon {
position: absolute;
left: 10px;
top: 10px;
}
BBCode - Click to Expand
[container:box-special][section:corner-icon fas fa-2x fa-book] [/section]
Your content
[/container]
Example in Action - Click to Expand
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Box with Background Image
Credit: Ademal
[container: con-img-background] [img:169171|nolink] [h1]Test[/h1] [p]Lorem ipsum dolor sit amet, consectetur
adipiscing elit. Vestibulum dapibus, augue at porttitor dapibus, enim nulla volutpat nunc, sit amet posuere leo
neque vel nibh. Integer mi mi, fermentum vitae ullamcorper venenatis, malesuada id nunc.
[br][br]Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
Cras blandit dictum arcu, tristique pellentesque tortor vestibulum in. Praesent in odio sit amet tellus
elementum convallis vitae ut nunc. Praesent tempus rutrum tincidunt. Nam vel viverra arcu.[/p] [/container]
CSS - Click to Expand
.user-css .con-img-background {
position: relative;
text-align: center;
}
.user-css .con-img-background h2 {
text-align: left;
padding: 10px 0px 5px 10px;
height: 2%;
margin: 0px;
border: none;
position: absolute;
width: 100%;
top: 1%;
}
.user-css .con-img-background img {
border-radius: 0px 10px 10px 10px;
opacity: 0.5;
}
.user-css .con-img-background .padding-10 {
background: black;
padding: 0px;
border-radius: 0px 10px 10px 10px;
}
.user-css .con-img-background img {
border-radius: 0px 10px 10px 10px;
opacity: 0.5;
}
.con-img-background p {
position: absolute;
top: 10%;
padding: 3%;
height: 100%;
border-radius: 0px 10px 10px 10px;
}
.user-css .con-img-background .artist-credits {
position: absolute;
bottom: 0;
width: 100%;
border-left: none;
border-right: none;
border-bottom: none;
border-radius: 0px 0px 10px 10px;
}
Tabs
Credit: User51
Check out the guide below to add tabs within one of your articles.
Accordion
Credit: User51
Check out the guide below to see how you can create an accordion in your article.
.user-css .box-special {
position: relative;
padding: 10px 10px 10px 50px;
border: purple solid 2px;
background: mediumpurple;
border-radius: 20px;
}
.user-css .box-special .corner-icon {
position: absolute;
left: 10px;
top: 10px;
}
[container:box-special][section:corner-icon fas fa-2x fa-book] [/section] Your content [/container]
.user-css .con-img-background { position: relative; text-align: center; } .user-css .con-img-background h2 { text-align: left; padding: 10px 0px 5px 10px; height: 2%; margin: 0px; border: none; position: absolute; width: 100%; top: 1%; } .user-css .con-img-background img { border-radius: 0px 10px 10px 10px; opacity: 0.5; } .user-css .con-img-background .padding-10 { background: black; padding: 0px; border-radius: 0px 10px 10px 10px; } .user-css .con-img-background img { border-radius: 0px 10px 10px 10px; opacity: 0.5; } .con-img-background p { position: absolute; top: 10%; padding: 3%; height: 100%; border-radius: 0px 10px 10px 10px; } .user-css .con-img-background .artist-credits { position: absolute; bottom: 0; width: 100%; border-left: none; border-right: none; border-bottom: none; border-radius: 0px 0px 10px 10px; }
CSS Guides
Bootstrap for Grandmasters (Part 2)
So it took my a while to figure that it doesnt like the literal word Description as part of the class name. The on the fly css editor always worked but reloading would break it and it would work again only when i hit space or anything on the on-the-fly editor. Regardless, it only worked properly on reload when i removed the word description for something else (i tried dozens of variation on the class name and description seemed to be the word it did not like). Would be nice to have a list of literal words that we should not use for class names in containers. Or a note that if the reload doesn't work it might be due to it (perhaps this is part of the security filter not liking it).
This is mentioned in the CSS on World Anvil Guide. description contains the word script which is removed by the security filter.