How do you set the full page background in Tailwind?
The only attribute I can see to use is h-screen
, but that doesn't work when I resize the browser.
Here's my code:
<body class="h-screen bg-gradient-to-b from-gray-100 to-gray-300">
Full html example:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>lkjh</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="css/main.css">
</head>
<body class="h-screen bg-gradient-to-b from-gray-100 to-gray-300">
<br />a<br />a<br /><br /><br /><br /><br /><br />a<br /><br /><br /><br />a<br /><br /><br />a<br /><br />a<br />a<br />a<br />a<br />a<br />
</body>
</html>
css file
@tailwind base;
@tailwind components;
@tailwind utilities;
"tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.0.2"
To add background color in HTML, use the CSS background-color property. Set it to the color name or code you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a table, heading, div, or span tag.
Go to Design > Page Color. Choose the color you want. If you don't see the color you want, select More Colors and then pick a color from any of the options in the Color box.
The magic happens with the background-size property: background-size: cover; cover tells the browser to make sure the image always covers the entire container, in this case html . The browser will cover the container even if it has to stretch the image or cut a little bit off the edges.
Change h-screen
to min-h-screen
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With