Use object-fit property instead of container element

This commit is contained in:
Luca 2023-03-12 20:20:24 +01:00
parent 7ebd00c633
commit db79aae55f
5 changed files with 20 additions and 45 deletions

View File

@ -8,6 +8,8 @@
a { a {
&.blur-on-hover { &.blur-on-hover {
overflow: hidden;
&:hover img { &:hover img {
filter: blur(5px); filter: blur(5px);
transform: scale(120%); transform: scale(120%);
@ -18,10 +20,6 @@
} }
} }
img {
display: block;
}
p { p {
background: rgba($color-overlay, 0.9); background: rgba($color-overlay, 0.9);
color: $color-overlay-text; color: $color-overlay-text;
@ -34,24 +32,9 @@
} }
img { img {
&.landscape { display: block;
height: 100%;
width: auto;
}
&.portrait {
height: auto;
width: 100%;
}
}
.image {
align-items: center;
display: flex;
height: 280px; height: 280px;
justify-content: center; object-fit: cover;
max-height: 280px;
width: 280px; width: 280px;
overflow: hidden;
} }
} }

View File

@ -158,33 +158,18 @@ nav {
article { article {
display: flex; display: flex;
& > .image {
display: none;
& > img {
height: auto;
width: 100%;
}
@media screen and (min-width: $small) {
display: block;
}
}
&.preview { &.preview {
margin-bottom: 3rem; margin-bottom: 3rem;
& > .image { & > img {
align-items: center; display: none;
height: 200px; height: 200px;
justify-content: center;
min-width: 200px;
overflow: hidden;
margin-right: 1.5rem; margin-right: 1.5rem;
width: 200px; min-width: 200px;
object-fit: cover;
@media screen and (min-width: $small) { @media screen and (min-width: $small) {
display: flex; display: block;
} }
} }
@ -195,9 +180,16 @@ article {
&.page { &.page {
& > .image { & > .image {
display: none;
text-align: right; text-align: right;
& > img {
height: auto;
width: 100%;
}
@media screen and (min-width: $small) { @media screen and (min-width: $small) {
display: block;
padding-left: 1.5em; padding-left: 1.5em;
width: 60%; width: 60%;
} }

View File

@ -5,7 +5,7 @@
{{ range .Pages }} {{ range .Pages }}
<a class="blur-on-hover" href="{{ .RelPermalink }}"> <a class="blur-on-hover" href="{{ .RelPermalink }}">
{{ with index (.Resources.ByType "image") 0 }} {{ with index (.Resources.ByType "image") 0 }}
<div class="image"><img alt="{{ .Title }}" class="{{ if lt .Height .Width }}landscape{{ else }}portrait{{ end }}" src="{{ .RelPermalink }}"></div> <img alt="{{ .Title }}" src="{{ .RelPermalink }}">
{{ end }} {{ end }}
<p>{{ .Title }}</p> <p>{{ .Title }}</p>
</a> </a>

View File

@ -3,7 +3,7 @@
{{ .Content }} {{ .Content }}
<section class="gallery"> <section class="gallery">
{{ range .Resources.ByType "image" }} {{ range .Resources.ByType "image" }}
<div class="image"><img alt="{{ .Title }}" class="{{ if lt .Height .Width }}landscape{{ else }}portrait{{ end }}" src="{{ .RelPermalink }}"></div> <img alt="{{ .Title }}" src="{{ .RelPermalink }}">
{{ end }} {{ end }}
</section> </section>
{{ end }} {{ end }}

View File

@ -6,7 +6,7 @@
<p class="date">{{ .Date | dateFormat "Mon, 02. January 2006" }}</p> <p class="date">{{ .Date | dateFormat "Mon, 02. January 2006" }}</p>
<article class="preview"> <article class="preview">
{{ with .Resources.GetMatch "image.jpg" }} {{ with .Resources.GetMatch "image.jpg" }}
<section class="image"><img alt="{{ .Title }}" src="{{ .RelPermalink }}"></section> <img alt="{{ .Title }}" src="{{ .RelPermalink }}">
{{ end }} {{ end }}
<section class="text"> <section class="text">
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2> <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
@ -31,7 +31,7 @@
{{ range first 4 (.Site.GetPage "/galerie").Pages }} {{ range first 4 (.Site.GetPage "/galerie").Pages }}
<a class="blur-on-hover" href="{{ .RelPermalink }}"> <a class="blur-on-hover" href="{{ .RelPermalink }}">
{{ with index (.Resources.ByType "image") 0 }} {{ with index (.Resources.ByType "image") 0 }}
<div class="image"><img alt="{{ .Title }}" class="{{ if lt .Height .Width }}landscape{{ else }}portrait{{ end }}" src="{{ .RelPermalink }}"></div> <img alt="{{ .Title }}" src="{{ .RelPermalink }}">
{{ end }} {{ end }}
<p>{{ .Title }}</p> <p>{{ .Title }}</p>
</a> </a>