css display
/******************* BASIC BLOCK DISPLAY **********************/
/**************** Block display Elements *********************/
/*Elements that block any other elements from being in the
same line. You can change the width from being the maximum
width of the page, but you can´t put elements side by side */
tag_name {
display: block;
}
/*Exemple of default block display elements:*/
<h1> ... </h1>
<p> ... </p>
/**************** Inline display Elements *********************/
/*They are the type of blocks that only take up the minimum space
required (both in width and height). You can place these types of
blocks side by side (on the same line) but you cannot change their
dimensions */
tag_name {
display: inline;
}
/*Exemple of default inline display elements:*/
<spans> ... </spans>
<img> ... </img>
<a> ... </a>
/************* Inline-block display Elements *****************/
/*They take the best of the two other types above. You can put
elements side by side (on the same line) and you can change this
block width and height */
tag_name {
display: inline-block;
}
/***************** None display Elements ********************/
/*This block will never appear on your webpage and will never
interact with the other elements (it doesn't take up space) */
tag_name {
display: none;
}
span.a {
display: inline; /* the default for span */
width: 100px;
height: 100px;
padding: 5px;
border: 1px solid blue;
background-color: yellow;
}
span.b {
display:
inline-block;
width: 100px;
height:
100px;
padding: 5px;
border: 1px
solid blue;
background-color: yellow;
}
span.c {
display: block;
width:
100px;
height: 100px;
padding: 5px;
border: 1px solid blue;
background-color: yellow;
}
/* Answer to: "css display grid" */
/*
The CSS Grid Layout Module offers a grid-based layout system,
with rows and columns, making it easier to design web pages
without having to use floats and positioning.
An HTML element becomes a grid container when its display property
is set to grid or inline-grid.
For more information, go to:
https://www.w3schools.com/css/css_grid.asp
*/
.grid-container {
display: grid;
}
/* or */
.grid-container {
display: inline-grid;
}
/*Compared to display: inline, the major difference is that
display: inline-block allows to set a width and height on the element.
Also, with display: inline-block, the top and bottom margins/paddings are
respected, but with display: inline they are not.
Compared to display: block, the major difference is that
display: inline-block does not add a line-break after the element,
so the element can sit next to other elements.
The following example shows the different behavior of
display: inline, display: inline-block and display: block: */
span.a {
display: inline; /* the default for span */
width: 100px;
height: 100px;
padding: 5px;
border: 1px solid blue;
background-color: yellow;
}
span.b {
display: inline-block;
width: 100px;
height: 100px;
padding: 5px;
border: 1px solid blue;
background-color: yellow;
}
span.c {
display: block;
width: 100px;
height: 100px;
padding: 5px;
border: 1px solid blue;
background-color: yellow;
}