There is a header and slider block, how to make the slider have a certain height (for example, 80% of the screen), and there is still section below? Set the height does not work in%, only in px.
#header { padding: 1%; position: relative; display: block; width: 100%; background-color: #7fb311; color: #fff; height: auto; } #slider { position: relative; margin: 0; height: 100%; width: 100%; background: url("https://static.pexels.com/photos/2946/dawn-nature-sunset-trees.jpg") center; background-size: 100%; } #slider .section { margin: 0 auto; width: 70%; background-color: #7fb311; color: #fff; } <div id="header"> HEADER </div> <div id="slider"> <div class="section"> AAA BBB CCC </div> </div>
sectionoccupy the rest of the space? - Vadim Ovchinnikovsectionbelow is no longer necessary? - Vadim Ovchinnikovsliderin the center, addedpostion: absolute; margin: autopostion: absolute; margin: auto, but thesectionremains at the bottom, but on the left is user7103883