2

I have a set up with several sections that have a full-screen width and height. Whether I position them absolute or relative the overflow still doesn't work.

DEMO

section {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

#a {
  background: linear-gradient(1deg, #9f00b8, #2a032d);
  position: absolute;
}

#b {
  background: linear-gradient(1deg, #25cc00, #2a032d);
  left: 100vw;
  position: relative;
}
Shniper
  • 854
  • 1
  • 9
  • 31

1 Answers1

1

Change your height: 100vh; and width: 100vw;

Like this:

width: 100%;
height: calc(100% - 0px);
// height: 100vh;
// width: 100vw;

And change the following line:

#b {
  background: linear-gradient(1deg, #25cc00, #2a032d);
  //left: 100vw;
   left: 100%;
  position: relative;
}

So i think calc is your solution maybe there are some other solution. Now you need browser support for calc.

width: -webkit-calc(100% - 0px);
width: -moz-calc(100% - 0px);
width: calc(100% - 0px);
height: -webkit-calc(100% - 0px);
height: -moz-calc(100% - 0px);
height: calc(100% - 0px);

I hope it will help.

Working fiddle

If you want to use vh with calc() you can check this answer It is possible to use vh minus pixels in a CSS calc()?

Community
  • 1
  • 1
AlwaysStudent
  • 1,354
  • 18
  • 49