Composition Component
The composition component creates an artistic arrangement of overlapping images with sophisticated hover interactions. It’s used in the About section to showcase nature photography with a dynamic, interactive layout.Overview
The composition component (.composition) arranges three images in an overlapping pattern with:
- Absolute positioning for precise placement
- Hover effects that highlight the focused image
- Shadow and outline effects
- Scale transformations on interaction
HTML Structure
index.html:84
Sass Implementation
sass/components/_composition.scss
Component Structure
Container (.composition)
The parent container uses relative positioning to establish a positioning context for the absolutely positioned photos.
Photos (.composition__photo)
Each photo is absolutely positioned with:
- Width: 55% of the container
- Box shadow: Subtle shadow for depth
- Position: Absolute for overlapping layout
- Transition: Smooth 0.2s ease for all properties
- Z-index: 10 (raised to 20 on hover)
Position Variants
Position 1 (.composition__photo--p1)
Position 2 (.composition__photo--p2)
Position 3 (.composition__photo--p3)
Hover Effects
Individual Photo Hover
When you hover over a single photo:- Outline: 1.5rem solid green border appears
- Transform: Scales to 105% and lifts up 0.5rem
- Shadow: Intensifies to a darker, larger shadow
- Z-index: Raised to 20, bringing it to the front
Non-Hovered Photos
When hovering over the composition, all photos NOT being hovered scale down to 95%:Visual Effect
The composition creates a photo collage effect:- Three images overlap at different depths
- Hovering highlights one image while dimming others
- The green outline matches the brand color
- Shadows create depth and hierarchy
Usage Context
Located in the About Section of the landing page:index.html:69
Key CSS Techniques
Absolute Positioning
Each photo is positioned absolutely within the relative container
Z-Index Layering
Controls stacking order, changing on hover to bring focused image forward
CSS Outline
Uses outline instead of border to avoid affecting layout dimensions
:not() Selector
Targets non-hovered siblings to create inverse hover effect
Design Considerations
- Outline offset: Set to 2rem to create spacing between image and outline
- Smooth transitions: 0.2s ease makes interactions feel polished
- Shadow progression: Lighter shadow at rest, darker on hover for depth
- Scale consistency: Small scale changes (95%-105%) prevent jarring motion
Accessibility
While the composition is primarily decorative, ensure:- Images have descriptive
alttext - The hover effect doesn’t hide critical content
- Color contrast of the outline is sufficient
Related Components
Story Component
Another component using shape-outside and clip-path for images
Cards
Similar hover effects with scale and shadow transformations