div.mydiv {
min-height: 100px;
}
The div will start at 100px, if the content pushes the div beyond 100px it will continue growing.
However if you have content that takes less than 100px it will still take 100px in space.@media query
is used for special devices.
In the example below @media query
is for devices with width less than or equal to 600px
#main {
width: 70%;
float: left;
padding: 0 30px;
box-sizing: border-box;
}
#sidebar {
width: 30%;
float: right;
padding: 0 30px;
box-sizing: border-box;
}
@media(max-width:600px) {
#main {
width: 100%;
float: none;
}
#sidebar {
width: 100%;
float: none;
}
}
flex
property is a shorthand for flex-grow
, flex-shrink
, and flex-basis
.
In this case the element with the property is going to take all the available width.stretch
that means all the flex items will be stretched vertically as default.container {
display: flex;
align-items: stretch;
}
margin-right
property:.container div {
margin-right: 40px;
}
.container div:last-child {
margin-right: 0px;
}
Flex way of space between flex items:.container {
display: flex;
justify-content: space-between;
}
.container div {
flex-basis: 30%;
}
@media (min-width: 900px) {
.container {
display: flex;
justify-content: space-between;
}
}
no-wrap
is the default value of the propertymargin: auto
is an alternative to justify-content: center
and align-items: center
.
Instead of this code on the flex container:
.container {
justify-content: center;
align-items: center;
}
We can use margin: auto
the flex item:.container div {
margin: auto;
}
(when there is only one flex item)row