cover.scss| Commit | Message |
|---|---|
ac75fabf3 | 2021-08-10 Github pages migrated to Asciidoc |
site/_sass/uikit/theme/ would add visual styling — but there IS no theme/cover.scss in the ProjectForge site. The cover uses UIkit defaults for its appearance..uk-cover {
max-width: none; // 1. Remove responsive width limit
position: absolute; // 2. Take out of document flow
left: 50%; top: 50%; // 3. Position top-left corner at center
transform: translate(-50%, -50%); // 4. Shift back by half width/height
}
.uk-cover-container {
overflow: hidden; // Clip content that exceeds container
position: relative; // Establish positioning context for .uk-cover
}
iframe.uk-cover { pointer-events: none; } // Clicks pass through to parentOn the ProjectForge site, documentation page heroes are rendered as:
<div class="uk-cover-container">
<img src="search.png" data-uk-cover> <!-- This becomes .uk-cover -->
<div class="uk-position-relative"> <!-- Content sits on top -->
<h1>Search</h1>
</div>
</div>UIkit's JavaScript adds the .uk-cover class and calculates dimensions dynamically. The CSS from this file provides the positioning. The overflow: hidden on the container ensures the cover image doesn't spill out if it's larger than the container.
pointer-events: none on iframes prevents the iframe from capturing clicks. Essential for embedded YouTube/Vimeo videos used as backgrounds — users must be able to interact with content ON TOP of the video.theme/cover.scss. All its visual styling comes from the content itself (the image) and the tile/section components that wrap it.data-uk-cover attribute triggers UIkit's JS to measure the container and set appropriate dimensions. The CSS alone doesn't make it cover — it needs the JS for dynamic sizing.
Line-by-line of the centering trick:
max-width: none: Removes any responsive width constraint. The cover element must be free to expand to cover the container, even if it exceeds the viewport width.position: absolute: Takes the element out of normal document flow. This is required forleft/topto work, and it needs the parent container to haveposition: relative(line 47).left: 50%; top: 50%: Positions the element's TOP-LEFT corner at the container's center. At this point, the element is offset — its top-left is centered, not the element itself.transform: translate(-50%, -50%): Shifts the element BACK by half its own width and height. The result: the element's CENTER is now at the container's center. This works because percentage values intranslate()refer to the element's own dimensions, not the parent's.This is arguably the most famous CSS centering pattern. Used on the ProjectForge site for hero background images — the documentation page headers with background photos.