Beispiel:CSS-offset-path-4.html

Aus SELFHTML-Wiki
Wechseln zu: Navigation, Suche
<!DOCTYPE html>
<html lang="de">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="./Beispiel:SELFHTML-Beispiel-Grundlayout.css">
  <style>
svg {
    --flugbahn: path('M200,100 a90,90 0 1,0 0,160 l300,-160 a90,90 0 1,1 0,160z');
    --plane-path: path('M15.1-6.2H3.4l-6.3-9.9c1.8-0.3,5.4-1.5,5.4-3.6s-4.8-3.6-6.3-3.6 \
	h-3.9l-4.5-6.9h-8.4l2.4,6.9 \
	h-0.3v7.2h3l3.6,9.9h-15.9l-6.6-6.6 h-4.8l5.7,9.6v7.8l-5.7,9.6h4.8l6.6-6.6h15.9l-3.6,9.6h-3v7.2 \
	h0.3l-2.4,6.9h8.7l4.5-6.9h3.9c1.5,0,6.3-1.5,6.3-3.6c0-1.8-3.6-3.3-5.4-3.6l6.3-9.9 \
	h11.7c3.9,0,18-2.7,18-6.9C33.1-3.5,19-6.2,15.1-6.2z');
}
.bahn {
	stroke: #337599;
	stroke-width: 1;
	d: var(--flugbahn);
	fill: transparent;
}

.plane {
	offset-path: var(--flugbahn);
	animation: run 6s linear infinite;
}
#yellow_plane {
	offset-rotate: auto;
}

#blue_plane {
	offset-rotate: 0deg;
	animation-direction: reverse;
}
.plane path {
    d: var(--plane-path);
}
@keyframes run {
	from {
		offset-distance: 0;
	}
	to {
		offset-distance: 100%;
	}
}

#hinweis {
	width: 90%;
}

  </style>
  <title>Beispiel: Animationen entlang eines Pfades - 3</title>
</head>
 
<body>
<h1>Animationen entlang eines Pfades<br>Ankerpunkt mit offset-rotate</h1>
<!-- Hinweis: Um Redundanzen zu vermeiden, werden die Pfade per CSS zugewiesen -->
<svg viewBox="0 0 700 400">
	<path class="bahn" />
	<g id="yellow_plane" class="plane">
		<path fill="#dfac20" />
		<circle r="3" fill="red" /> </g>
	<g id="blue_plane" class="plane">
		<path fill="#3983ab" />
		<circle r="3" fill="red" /> </g>
</svg>
<div id="hinweis">
	<p>Das Beispiel funktioniert (Stand: Februar 2021) nicht im Safari.</p>
</div>
</body>
</html>