#I'd like to change the background colour of the `body` element in Fresh. How do I do that simply?
7 messages · Page 1 of 1 (latest)
could you elaborate on why you need the body element specifically?
When the user scrolls past the full height of the page, the background of the outer part of the page must match the inner part of the page. Does that make sense?
Sorry for the late reply... Thank you! Do you know how I can do this for a single page within a project? I've tried adding a body with a custom class in the page component. However, this invalidates the HTML as there are now two body elements.
If you're using CSS files to style, couldn't you just use the body selector and do something like:
body {
background-color: pink;
}
If you don't have a CSS file somewhere for styling, I think you can pull them in like this:
import { Head } from "$fresh/runtime.ts";
// in your JSX
<Head>
<link href="path/to/your/styles.css" rel="stylesheet" />
</Head>
If I'm not mistaken, the _app.tsx would have to because it would have to be in the static folder https://fresh.deno.dev/docs/concepts/static-files
import { Head, asset } from "$fresh/runtime.ts";
<Head>
<link href={asset("/global.css")} rel="stylesheet" />
</Head>
Fresh has built-in support for serving static files. This is useful for serving images, CSS, and other static assets.