Restricting the height of the body to 100% of the screen height is causing the background not to stay at full 100%

How is that fixed. https://jsfiddle.net/3cgqpkrf/

Background no-repeat; is causing the background not to stay at 100%

How would I fix or adjust that in the code so that the background stays at 100%?

body {
  background: linear-gradient(45deg, #102eff, #d2379b);
  background-repeat: no-repeat;
}

Add this :
background-position: center;
background-size : cover;

That does not work to fix the issue.

Has no effect.

Still occurs.

Hi @javascriptcoding5678,

You can use the property background-attachment with the value fixed, it should give you the result you are expecting.

That may not be a good way.

I just read this.

Background attachment fixed has problems on mobile.

I added a fixed height on the body just to test and I didn’t meet the issue this guy is encountering. After I didn’t test on mobile device. In the comments of that article, there is an interesting suggestion, to add the background-attachment to the html itself, not the body. You can try all of this and tell us what is your analyze.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.