Skip to content

Commit

Permalink
fix: responsive aspect ratios don't work with intermediate elements (#…
Browse files Browse the repository at this point in the history
…5402)

* Handle intermediate image container divs

* Tweak responsive example

* change aspect ratios
  • Loading branch information
jmuzina authored Oct 30, 2024
1 parent ce8551b commit 6b77a8d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vanilla-framework",
"version": "4.18.0",
"version": "4.18.1",
"author": {
"email": "[email protected]",
"name": "Canonical Webteam"
Expand Down
5 changes: 5 additions & 0 deletions scss/_patterns_image.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ $aspect-ratios: (
justify-content: center;
text-align: center;

// If there is a child element that is not the image, don't let it affect the layout
& > *:not(.p-image-container__image) {
display: contents;
}

&.is-highlighted {
background: $colors--theme--background-alt;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
{% block standalone_css %}patterns_image{% endblock %}

{% block content %}
<div class="p-image-container--cinematic-on-large p-image-container--16-9-on-medium p-image-container--2-3-on-small is-highlighted">
<img class="p-image-container__image"
src="https://assets.ubuntu.com/v1/9b4c074f-Kernelt%20industries-80-short.png" width="300" alt="">
<div class="p-image-container--square-on-small p-image-container--16-9-on-medium p-image-container--cinematic-on-large is-highlighted">
<div class="lazyloaded">
<img src="https://assets.ubuntu.com/v1/f74cb1d3-streaming%20data.png" alt="" width="852" height="1279" loading="lazy" class="p-image-container__image">
</div>
</div>
{% endblock %}

0 comments on commit 6b77a8d

Please sign in to comment.