CSS (Cascading Style Sheet) definiert die Darstellung einer Website in HTML. * [[https://www.w3schools.com/cssref/css_selectors.asp|Selektoren]] * [[https://www.w3schools.com/cssref/css_animatable.asp|Animationen]] * [[https://www.w3schools.com/cssref/css_functions.asp|Funktionen]] * [[https://www.w3schools.com/Css/css3_mediaqueries_ex.asp|Media Queries]] =====Positionierung===== * **static** (Standard): Das Element wird im normalen HTML-Fluss positioniert. * **relative**: Das Element wird relativ zur normalen Position verschoben. Dabei bleibt der Raum, den es normalerweise einnehmen würde, erhalten. * **absolute**: Das Element wird relativ zum nächstgelegenen positionierten Vorgängerelement verschoben, wenn es eins gibt. Andernfalls wird es relativ zum Ancestor verschoben, der den position: relative-Wert hat. * **fixed**: Das Element wird relativ zum Browserfenster positioniert und bleibt dort, auch wenn die Seite gescrollt wird. * **sticky**: Das Element verhält sich wie relative, bis es die angegebene Schwelle erreicht, dann wird es verhält es sich wie fixed. [[https://jsfiddle.net/w2af3hp4/|Positions - JSFiddle]] =====Masseinheiten===== CSS verfügt über mehrere verschiedene Einheiten zum Ausdrücken einer Länge wie "width", "height" usw. Die Länge ist eine Zahl gefolgt von einer Längeneinheit, z. B. 10 Pixel, 2 Em usw. Es gibt absolute Einheiten * cm - centimeters * mm - millimeters * in - inches (1in = 96px = 2.54cm) * px - pixels (1px = 1/96th of 1in) * pt - points (1pt = 1/72 of 1in) * pc - picas (1pc = 12 pt) Relative Masseinheiten * em - Relative to the font-size of the element (2em means 2 times the size of the current font) * ex - Relative to the x-height of the current font (rarely used) * ch - Relative to the width of the "0" (zero) * rem - Relative to font-size of the root element * vw - Relative to 1% of the width of the viewport* * vh - Relative to 1% of the height of the viewport* * vmin - Relative to 1% of viewport's* smaller dimension * vmax - Relative to 1% of viewport's* larger dimension * % - Relative to the parent element =====Elemente===== CSS Elemente werden anhand ihrer "Klasse" oder "Id" identifiziert. Mehrere Elemente können die selbe "Klasse" haben, "Id"s sollten aber eindeutig sein um eindeutigen Zugriff auf Elemente zugewährleisten. (siehe Selektoren) In der Definition (dem Stylesheet) werden "Klassen" mit einem "." (Punkt) davor gekennzeichnet, "Id"s mit einer "#" (Raute).
a
b
c
=====Grid===== [[https://www.youtube.com/watch?v=EiNiSFIPIQE|CSS Grid Tutorial]] =====Animations===== [[https://www.youtube.com/watch?v=SgmNxE9lWcY|CSS Animations in 20 minutes]] =====Responsive Video Container===== .video-container { position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden; } .video-container iframe, .video-container object, .video-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
=====FullScreen Image Banner =====
Introduction
=====calc===== You can use variables and calculate them.
Hello world
=====Animationen===== @keyframes splash { 0% { opacity: 0; transform: scale(0, 0); } 50% { opacity: 1; transform: scale(1.1, 1.1); } 100% { transform: scale(1, 1); } } @keyframes splash { from { opacity: 0; transform: scale(0, 0); } to { transform: scale(1, 1); } } #div { animation: splash 1s normal forwards ease-in-out; } =====Pseudo Elements=====
Fake Dropdown
=====Variablen===== Define Variables: To define a variable, use the -- prefix followed by the variable name and the value you want to assign to it. Variables are typically defined in the :root pseudo-class, which makes them available globally throughout the stylesheet. :root { --primary-color: #007bff; --font-size-large: 18px; } 2. Use Variables: You can use variables by referencing them using the var() function. This function takes the variable name as an argument and returns its value. body { font-size: var(--font-size-large); color: var(--primary-color); } 3. Updating Variables: Changing the value of a variable is as simple as modifying it in the :root block. This change will be automatically applied wherever the variable is used. :root { --primary-color: #ff9900; } 4. Fallback Values: You can provide a fallback value for variables in case they are undefined. This can be helpful for maintaining compatibility with older browsers. body { background-color: var(--background-color, white); } 5. Scoping: Variables are scoped to their respective elements. If you define a variable within a specific selector, it will only be available within that scope and its children. .button { --button-color: red; background-color: var(--button-color); } =====Links===== * Path & Clipping https://css-tricks.com/clipping-masking-css/ * CSS fullscreen background video: https://slicejack.com/fullscreen-html5-video-background-css/ * Media Queries: [[https://www.w3schools.com/css/css_rwd_mediaqueries.asp|3]] * Pure CSS Tabs: https://codepen.io/renatorib/pen/rlpfj * Pure CSS Accordeon: https://codepen.io/raubaca/pen/PZzpVe