The inline-block Value
It has been possible for a long time to create a grid of boxes that fills the
browser width and wraps nicely (when the browser is resized), by using the
float property.
However, the
inline-block value of the display
property makes it is even easier.
inline-block elements are like inline elements but they can have a width and
height.
Examples
The old way - using
float (notice that we also need to specify a
clear property for the element after the floating boxes):Example
.floating-box {
float: left;
width: 150px;
height: 75px;
margin: 10px;
border: 3px solid #8AC007;
}
.after-box {
clear: left;
}
float: left;
width: 150px;
height: 75px;
margin: 10px;
border: 3px solid #8AC007;
}
.after-box {
clear: left;
}
The same effect can be achieved by using the
inline-block value
of the display property (notice that no clear property is needed):Example
.floating-box {
display: inline-block;
width: 150px;
height: 75px;
margin: 10px;
border: 3px solid #8AC007;
}
display: inline-block;
width: 150px;
height: 75px;
margin: 10px;
border: 3px solid #8AC007;
}
No comments:
Post a Comment