Hi Astro,
I'm very new to astro, so it could very well be that I'm misusing some concepts. In short, what I'm currently trying to do: Apply styles to direct descendants of the layout I'm using for a page.
This is my setup:
I have a BaseLayout, and its stripped contents are:
---
import Header from "../components/Header.astro";
import Footer from "../components/Footer.astro";
import "../styles/global.css";
---
<html>
<head>...</head>
<body>
<Header />
<main>
<!-- I'm trying to style the slotted contents -->
<!-- So the direct descendants of the main element -->
<slot />
</main>
<Footer />
</body>
</html>
Now my (stripped) index page looks as follows:
---
import BaseLayout from "../layouts/BaseLayout.astro";
---
<style>
& > div {
padding-inline: 2rem;
outline: 2px solid red;
}
</style>
<BaseLayout >
<!-- Trying to write a css selector for these top-level divs here -->
<div>Section 1...</div>
<div>Section 2...</div>
</BaseLayout>
Now I would like to apply some styles only to the 'top-level' divs inside the BaseLayout. How do I go about this? I've tried adding selectors based on the parent, but this of course doesn't work, since the styles are scoped. Maybe I have the wrong division between what is part of my BaseLayout and what is part of the styling of the contents?
Kind regards,
Auke