Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background image fitting content #472

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ function decorateSectionsWithBackgrounds(element) {
const backgroundPic = createOptimizedPicture(background);
backgroundPic.classList.add('background-image');
section.append(backgroundPic);
if (section.querySelector('.section-container')?.children.length === 0) {
section.classList.add('no-content');
}
}
});
}
Expand Down
16 changes: 16 additions & 0 deletions styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,24 @@
--split-lastthird: 66%:34%;
}


*, *::before, *::after { box-sizing: inherit; }

/* this selects the sections that have a background image and other blocks
and sets them as the container for the query below
sections with background images only get ignored */
div.section.with-background-image:not(.no-content) {
container-name: text-container;
container-type: inline-size;
}

/* this updates the height of the content inside the section */
@container text-container (max-width: 991px) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By convention, we are following min-width. Could you please adjust for the same? Basically make this the default style. BTW, does it make sense to have this apply to wide screens as well?

body > main > div.with-background-image > picture img {
height: 100cqh;
}
}

html {
scroll-behavior: smooth;
box-sizing: border-box;
Expand Down