Skip to content

Media

the Media-element dient zur Display verschiedener Medieninhalte how images, Videos and Audioelemente. it bietet einheitliche Styling-Optionen and responsive customizations for multimediale contents.

Installation

the Media-element ist Teil the Casoon UI Library.

bash
# Installation the gesamten Bibliothek
npm install @casoon/ui-lib

Import

css
/* Import aller UI-elements */
@import '@casoon/ui-lib/ui.css';

/* or only the Media-Components */
@import '@casoon/ui-lib/media.css';

Basic Usage

images

html
<img class="media" src="path/to/image.jpg" alt="Description des Bildes">
Examplebild

Videos

html
<video class="media" controls>
  <source src="path/to/video.mp4" type="video/mp4">
  her Browser unterstutzt no Videowiedergabe.
</video>
Video-Player (Example)

Audio

html
<audio class="media" controls>
  <source src="path/to/audio.mp3" type="audio/mp3">
  her Browser unterstutzt no Audiowiedergabe.
</audio>
Audio-Player (Example)

Variants

responsive images

with verschiedenen Bildquellen for unterschiedliche Bildschirmgrossen:

html
<picture>
  <source media="(min-width: 1200px)" srcset="path/to/large.jpg">
  <source media="(min-width: 768px)" srcset="path/to/medium.jpg">
  <img class="media" src="path/to/small.jpg" alt="Responsives image">
</picture>

Bildverhaltnis-containers

containers, the the Seitenverhaltnis beibehalten:

html
<div class="media-containers ratio-16-9">
  <img src="path/to/image.jpg" alt="image with festem Seitenverhaltnis">
</div>
image with 16:9 Verhaltnis

Abgerundete Medien

html
<img class="media rounded" src="path/to/image.jpg" alt="Abgerundetes image">
Abgerundetes image

Kreisformige Medien

html
<img class="media circle" src="path/to/image.jpg" alt="Kreisformiges image">
Kreisformiges image

with shadow

html
<img class="media shadow" src="path/to/image.jpg" alt="image with shadow">
image with shadow

with border

html
<img class="media bordered" src="path/to/image.jpg" alt="image with border">
image with border

with Bildunterschrift

html
<figure class="media-figure">
  <img class="media" src="path/to/image.jpg" alt="image with Bildunterschrift">
  <figcaption>Description des Bildes or Urheberrechtshinweis</figcaption>
</figure>
image with Bildunterschrift
Description des Bildes or Urheberrechtshinweis

Medien-Galerie

html
<div class="media-gallery">
  <img class="media" src="path/to/image1.jpg" alt="image 1">
  <img class="media" src="path/to/image2.jpg" alt="image 2">
  <img class="media" src="path/to/image3.jpg" alt="image 3">
  <img class="media" src="path/to/image4.jpg" alt="image 4">
</div>
Galeriebild 1Galeriebild 2Galeriebild 3Galeriebild 4

Customization

the Media-elements can over CSS Variables angepasst become:

css
:root {
  /* Grundlegende Media-properties */
  --media-max-width: 100%;
  --media-border-radius: var(--radius-md);
  --media-margin: 0;
  
  /* Spezialisierte Media-Variants */
  --media-rounded-radius: var(--radius-lg);
  --media-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --media-border-color: var(--color-gray-200);
  --media-border-width: 1px;
  
  /* containers and Figuren */
  --media-figure-margin: var(--space-4) 0;
  --media-caption-color: var(--color-gray-600);
  --media-caption-font-size: var(--font-size-sm);
  --media-caption-margin: var(--space-2) 0 0;
  
  /* Galerien */
  --media-gallery-gap: var(--space-2);
  --media-gallery-columns: 2;
}

Accessibility

  • Verwende immer a aussagekraftiges alt-attributes for images
  • Fuge Untertitel and Beschreibungen for Video- and Audioelemente hinzu
  • Stelle sicher, that Steuerungen for Video- and Audioelemente with the Tastatur bedienbar sind
  • Verwende the loading="lazy"-attributes for images, um the Ladezeit to verbessern
  • Nutze the picture-element and responsive Quellen for bessere Performance

Browser-Kompatibilitat

the Media-element ist with allen modernen Browsern kompatibel.

FunctionChromeFirefoxSafariEdge
Grundlegende Bilddarstellung
Video- and Audio-elements
Picture-element
Aspect-Ratio-containers
Lazy Loading
CSS Variables49+31+9.1+15+