Enhance images by distinguishing them from their background or controlling their container's aspect ratio.
Insulate an image from its surroundings. This can help to emphasize the image and/or prevent its white space from becoming indistinguishable from the surrounding white space.
You can modify the aspect ratio of an image container to neatly wrap an image in a container of the desired aspect ratio. This is useful for aligning images or other content with mismatching aspect ratios.
All image containers center the .p-image-container__image
element inside them by default.
If you need to change image alignment within the image container, use the image position utility.
See the class references section for more information on the available aspect ratio classes.
Cover images are used to fill the entire container, cropping the image if necessary. This can be combined with the aspect ratio modifier to crop the image to a specific aspect ratio.
A simple key-line around your image.
Add depth using our drop shadow around your image.
When an image needs a caption, it can be wrapped in a <figure>
element, along with a <figcaption>
.
Adds spacing to the top of a media element. This is usually needed when image or video is placed below the horizontal rule component to avoid media touching the line.
.p-image-container
Main element of the image component.
&.is-highlighted
Highlighted variant, to be used to highlight contents.
.p-image-container--16-9
Wraps contents in a container with an aspect ratio of 16:9.
.p-image-container--3-2
Wraps contents in a container with an aspect ratio of 3:2.
.p-image-container--2-3
Wraps contents in a container with an aspect ratio of 2:3.
.p-image-container--cinematic
Wraps contents in a container with an aspect ratio of 2.4:1.
.p-image-container--square
Wraps contents in a container with an aspect ratio of 1:1.
.p-image-container__image
Image element within an image container.
To import just this component into your project, copy the snippet below and include it in your main Sass file.
// import Vanilla and include base mixins
// this only needs to happen once in a given project
@import 'vanilla-framework';
@include vf-base;
@include vf-p-image;
For more information see Customising Vanilla in your projects, which includes overrides and importing instructions.