Skip to Navigation
< Return to Ferrigan Design Websites Page

Lesson 12 Final Exam Project

Media Patterns

Image

This is an image with a caption and citation.

HTML

<figure class="filter-image" tabindex="0">
    <picture>
        <source srcset="images/RedSquare_Tuthill.jpg" type="image/jpg">
        <img src="RedSquare_Tuthill-250.jpg" alt="NASA astronomy
         picture of the day" tabindex="0">
    </picture>
    <figcaption>The Red Square Nebular - MWC992</figcaption>
    <div class="image-source"><a href="https://apod.nasa.gov/apod/ap210926.html">
     Source: NASA APOD</a></div>
</figure>

CSS

.media-img {
    background-color: var(--main-med-light-color);
    border: solid thin var(--main-med-dark-color);
    box-shadow: 5px 5px 10px var(--main-dark-color);
    border-radius: .5rem;
    width: 25rem;
    margin: auto;
    padding: 1rem;
}
.filter-image {
    width: 23rem;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}
.filter-image picture {
    grid-area: 1 / 1;
    overflow: hidden;
}
.filter-image figcaption {
    grid-area: 1 / 1;  /* With the figure caption and picture element placed in the same grid area, the caption will overlay the image. */
    background-color: hsla(0 0% 0% / .5);
    color: var(--main-light-color);
    padding: .5rem;
    height: max-content;  /* to ensure the caption will only take enough space to show the text an not the whole grid area */
    text-align: center;
    transform: rotateX(-90deg);
    transition-duration: 200ms;
    transition-property: all;
    transform-origin: top;
}
figure.filter-image:hover figcaption, figure.filter-image:focus figcaption {
    transform: rotateX(0deg);
}
.filter-image img {
    width: 100%;
    filter: blur(2px);  /* blur has to come first to match example */
    filter: saturate(30%);  /* saturate doesn't seem to work if blur isn't first */
}
.filter-image img:hover, .filter-image img:focus {
    filter: saturate(100%);
    transform: scale(1.15);
}
.filter-image {
    font-size: .85em;
    margin-top: .5rem;
}

Example

NASA astronomy picture of the day
The Red Square Nebular - MWC992