george Posted February 7, 2016 Share Posted February 7, 2016 I have been trying to create a page with a color gradient background using CSS: body { background-image:-moz-linear-gradient(top, #000029 50%, #000080 100%); } But when I render the page, the gradient extends only as far as the content, and then repeats to fill the screen. How can I make it so that it renders the gradient to the full browser window, regardless of the content? When I replace the body background-image attribute with a background-color attribute, it renders to the full screen, as I would expect. Perhaps this can not be done, or maybe there is a workaround? Link to comment Share on other sites More sharing options...
Ingolme Posted February 7, 2016 Share Posted February 7, 2016 The body is usually only as large as the content within it, but you can fix that by setting the height of the html and body elements. THe -moz- prefix will only work in Firefox, use -webkit- and the plain CSS property to make sure it works in the widest range of browsers. I believe the first parameter needs to be "to top", "to bottom", "to left", "to right" or a numeric value. html,body { margin: 0; padding: 0; } html { height: 100%; } body { min-height: 100%; background-image: -webkit-linear-gradient(to top, #000029 50%, #000080 100%); background-image: -moz-linear-gradient(to top, #000029 50%, #000080 100%); background-image: linear-gradient(to top, #000029 50%, #000080 100%) } 1 Link to comment Share on other sites More sharing options...
george Posted February 7, 2016 Author Share Posted February 7, 2016 That did it. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now