Closed sunmingtao closed 4 years ago
html
<div class="book"></div>
css
.book { background-image: url('../img/nat-10.jpg'); background-size: cover; //height: 50rem; }
Without the height attribute, nothing displays. Inspect the element, the height of the div is 0.
height
This is because the div doesn't have any contents, so the height is 0. Add some contents and see the difference. e.g. <div class="book">Add some contents</div>
<div class="book">Add some contents</div>
html
css
Without the
height
attribute, nothing displays. Inspect the element, the height of the div is 0.