Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set a full page background color in Tailwind css?

Tags:

tailwind-css

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.

enter image description here

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"

like image 363
Richard Avatar asked Feb 03 '21 10:02

Richard


People also ask

How do you specify a background color on an entire page?

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.

How do you color the whole page?

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.

How do I make a background image fit the whole page CSS?

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.


Video Answer


1 Answers

Change h-screen to min-h-screen

like image 197
Digvijay Avatar answered Oct 16 '22 11:10

Digvijay