2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Inline Block
|
|
|
|
---
|
|
|
|
## Inline Block
|
2018-12-31 14:41:23 +08:00
|
|
|
inline-block is a possible value of the display property.
|
2018-10-12 15:37:13 -04:00
|
|
|
Elements marked as _inline-block_ behave like inline elements (_spans_, for example), but can have width and height.
|
|
|
|
|
2018-12-31 14:41:23 +08:00
|
|
|
You can add inline-block to navigation so it is displayed horizontally instead of vertically.
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2018-12-31 14:41:23 +08:00
|
|
|
HTML:
|
|
|
|
|
|
|
|
```html
|
|
|
|
<ul class="nav">
|
|
|
|
<li><a href="#">Home</a></li>
|
|
|
|
<li><a href="#">About Me</a></li>
|
|
|
|
<li><a href="#">Blog</a></li>
|
|
|
|
<li><a href="#">Contact</a></li>
|
|
|
|
</ul>
|
|
|
|
```
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2018-12-31 14:41:23 +08:00
|
|
|
CSS:
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2018-12-31 14:41:23 +08:00
|
|
|
```css
|
|
|
|
.nav li {
|
|
|
|
display: inline-block;
|
|
|
|
padding: 20px;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
#### More Information:
|
|
|
|
[CSS-Tricks - inline-block](https://css-tricks.com/almanac/properties/d/display/#inline-block)
|