Seite 1 von 1

Ein Problem mit aspect-ratio

Verfasst: So 5. Jul 2026, 10:13
von stobi_de
Morgen!
ich will für meinen Blog die Ansicht der Titelbilder einstellbar machen.
https://www.afripix-web.de/blog-webdesi ... -wiehl.php
Aber die Ansicht ist immer 1:1. (auch mit ChatGPT schon gesucht)

Code: Alles auswählen

<input type="radio" title="Bildformat Übersicht 1:1" name="imageRatio" value="square">
<input type="radio" title="Bildformat Übersicht 4:3" name="imageRatio" value="portrait" checked>
<input type="radio" title="Bildformat Übersicht 16:9" name="imageRatio" value="wide">

.blog-image {
  width: 100%;
  overflow: hidden;
  background: #f2f2f2;
}
.blog-image-ratio {
  aspect-ratio: (1 / 1);
}
& when (@imageRatio = portrait) {
  .blog-image-ratio {
    aspect-ratio: (4 / 3);
  }
}
& when (@imageRatio = wide) {
  .blog-image-ratio {
    aspect-ratio: (16 / 9);
  }
}

Re: Ein Problem mit aspect-ratio

Verfasst: So 5. Jul 2026, 10:17
von Volker
Gib mir mal den ganzen Block, bau ich dir schnell ;)

Re: Ein Problem mit aspect-ratio

Verfasst: So 5. Jul 2026, 10:19
von stobi_de
Danke, aber schon gefunden: muss mit Anführungszeichen sein

Code: Alles auswählen

& when (@imageRatio = 'portrait')