Home > Software design >  How to cover the entire height of a div?
How to cover the entire height of a div?

Time:10-19

When I press the "push me" button, the green cover is down to the third item. However, there is still space after scrolling down. I need to cover the entire height of div (it is better to use the pseudo-element "after"). How I can do it?

.cover:after {
  padding: 0;
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  top: 0;
  z-index: 99;
  height: 100%;
  width: 100%;
  content: "Cover, cover, cover";
  background: green url("src/img.svg") no-repeat 50% 33%;
  font-weight: 600;
  font-size: 18px;
  text-align: center;
  color: white;
}

Full code: https://codepen.io/Roman-H91/pen/eYroQPq

CodePudding user response:

You can add the property overflow:clip to keep all the height

.cover {
  overflow:clip;
}
  • Related