Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
YouTube Security VideosAndroid Police: Samsung is smashing records! #shorts #tech #phones(21.09.2026 um 13:55 Uhr)
YouTube Security Videosheise & c't: Bundesnetzagentur wollte diesen Futterautomaten verbieten(21.09.2026 um 13:53 Uhr)
YouTube Security VideosNeil Patel: Your Google Traffic Isn't An Asset It's A Loan #shorts(21.09.2026 um 14:05 Uhr)
Windows Tipps & SecurityF-14 A Tomcat Top Gun endlich als Revell Klemmbausteinmodell erhältlich(21.09.2026 um 14:27 Uhr)
Sichere ProgrammierungShow the Hand-Back Sample Before Approving an Agent Score(21.09.2026 um 14:15 Uhr)
Sichere ProgrammierungHybrid retrieval in one Postgres query: RRF over tsvector + pgvector(21.09.2026 um 14:15 Uhr)
YouTube Security VideosAndroid Police: Samsung is smashing records! #shorts #tech #phones(21.09.2026 um 13:55 Uhr)
YouTube Security Videosheise & c't: Bundesnetzagentur wollte diesen Futterautomaten verbieten(21.09.2026 um 13:53 Uhr)
YouTube Security VideosNeil Patel: Your Google Traffic Isn't An Asset It's A Loan #shorts(21.09.2026 um 14:05 Uhr)
Windows Tipps & SecurityF-14 A Tomcat Top Gun endlich als Revell Klemmbausteinmodell erhältlich(21.09.2026 um 14:27 Uhr)
Sichere ProgrammierungShow the Hand-Back Sample Before Approving an Agent Score(21.09.2026 um 14:15 Uhr)
Sichere ProgrammierungHybrid retrieval in one Postgres query: RRF over tsvector + pgvector(21.09.2026 um 14:15 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

CSS Is Not Hard(You 're Just Missing These Basics)- Mastering the Foundation(Part 2)

Thank you all for the comments on the last article, it really does mean a lot. I hope you learn one or two things from this article. In this article, we'll explore two fundamental concepts in CSS—positioning and layout. Positioning and l…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Thank you all for the comments on the last article, it really does mean a lot. I hope you learn one or two things from this article.



In this article, we'll explore two fundamental concepts in CSS—positioning and layout. Positioning and layout are at the heart of creating visually appealing and functional webpages. Mastering these concepts allows you to craft responsive designs that enhance user experience. By the end, you'll know how to use these techniques to structure your webpages like a pro.



- Positioning and Layout



CSS Positioning controls how elements are positioned or placed on a web page. Positioning is influenced by the offset values Top, Bottom, Left and Right when applicable. There are 5 main CSS Position values;



1. Static: All HTML elements are positioned static by default. This simply means the element is unchanging and does not move and is not influenced by the offset values Top, Bottom, Left and Right.



2. Relative: Elements are positioned relative to their normal position.



3. Absolute: Elements are positioned relative to their nearest ancestor(parent) or the viewport.



4. Fixed: Elements are positioned relative to the viewport and remain fixed during scrolling.



5. Sticky: Sticky positioning allows an element to switch between relative and fixed positions based on scroll position and offset values Top, Bottom, Left and Right.



Below is an illustration that explains CSS positioning.



CSS Positioning



Here is the code that helped bring the illustration to life. Feel free to copy and modify on your own.




<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Positioning</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="static">
<h2>Static Position</h2>
<p>This div has a static position. It is positioned relative to its normal position, which means it will not be affected by the positioning properties of other elements.</p>
</div>
<div class="relative">
<h2>Relative Position</h2>
<p>This div has a relative position. It is positioned relative to its normal position, and it can be moved using the top, bottom, left, and right properties.</p>
</div>
<div class="absolute">
<h2>Absolute Position</h2>
<p>This div has an absolute position. It is positioned relative to the nearest positioned ancestor, which means it will be affected by the positioning properties of other elements.</p>
</div>
<div class="fixed">
<h2>Fixed Position</h2>
<p>This div has a fixed position. It is positioned relative to the viewport, which means it will stay in the same place even when scrolling.</p>
</div>
<div class="sticky">
<h2>Sticky Position</h2>
<p>This div has a sticky position. It is positioned relative to the nearest positioned ancestor, but it will not be affected by the positioning properties of other elements. It will stay in its original place until it crosses a specified threshold.</p>
</div>
</div>
</body>
</html>










*{
margin: 0;
padding: 0;
box-sizing: border-box;
}

body{
font-family: Arial, sans-serif;
background-color: #f2f2f2;
display: grid;
place-content: center;
min-height: 100vh;
}

.container{
width: 100%;
max-width: 1200px;
height: auto;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
border: 1px solid red;
gap: 20px;
padding: 20px;
}

.static{
background-color: #ccc;
padding: 20px;
border: 1px solid black;
width: 300px;
position: static;

}

.relative{
background-color: #ccc;
padding: 20px;
border: 1px solid black;
width: 300px;
position: relative;
top:30px;
right: 30px;

}

.absolute{
background-color: #ccc;
padding: 20px;
border: 1px solid black;
width: 300px;
position: absolute;
top: 30px;
right: 100px;
}

.fixed{
background-color: #ccc;
padding: 20px;
border: 1px solid black;
width: 300px;
position: fixed;
bottom: 0;
right: 0;
}

.sticky{
background-color: #ccc;
padding: 20px;
border: 1px solid black;
width: 300px;
position: sticky;
top: 0;
right: 0;
}







— Pause, Take a deep breath, and then proceed!!—

- CSS Layout



1. Flexbox: This is a one-dimensional layout method used for laying items out in a single axis (horizontally and vertically).



Features of a flexbox





  • display: flex - This creates a flexbox for the container.


  • align-items: center - This controls the container's vertical alignment.


  • justify-content: space-between - This controls the container's horizontal alignment.


  • gap: adds spacing between flex items without needing margins.



Here's the before and after of a simple Navigation Bar




<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Navigation Bar using CSS Flexbox</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">

<nav>

<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</div>
</body>
</html>










* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
min-height: 100vh;
}

li {
list-style: none;
}
a {
text-decoration: none;
color: white;
}
nav {
background-color: #333;
color: #fff;
padding: 10px;
}

ul {
display: flex;
align-items: center;
gap: 2rem;
}







Result:



Navigation Bar before using CSS Flexbox



Navigation Bar after using CSS Flexbox



2. Grid: This is a 2-dimensional layout method used in creating rows and columns.



Features





  • display: grid - This creates a Grid for the container.


  • grid-template-columns/grid-template-rows - This defines a row or column for the container.


  • repeat(2, 1fr) - This creates 2 equal-width columns.


  • gap: 10px- Adds spacing between grid items.



Here is a before and after of some cat photos i found on Unsplash.




<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CSS Grid using Cat Photos</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container">
<div class="cat-photos">
<img src="path-to-your-image/cat-one.jpg" alt="Cute cat" />

<img src="path-to-your-image/cat-two.jpg" alt="Cute cat" />

<img src="path-to-your-image/cat-three.jpg" alt="Cute cat" />

<img src="path-to-your-image/cat-four.jpg" alt="Cute cat" />
</div>
</div>
</body>
</html>










* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
min-height: 100vh;
}

.container {
margin: 0 auto;
width: 950px;
padding: 1rem;
}

.cat-photos {
padding: 2rem;
display: grid;
grid-template-columns: repeat(2, 1fr); /* Creates 2 equal-width columns */
}

img {
border: 5px solid white;
border-radius: 10px;
width: 250px;
height: 250px;
}







Result:






Cat Photos before using CSS Grid



Cat Photos after using CSS Grid



Comparison Table

































Feature Flexbox Grid
Axis One-dimensional Two-dimensional
Alignment Horizontal/Vertical Rows and columns
Best for Navigation Bars Layouts like dashboards
Flexibility Better for small components Better for page layouts


Positioning and Layout are the foundation of CSS. Understanding when and how to use them will not only make your styling experience easier but also more enjoyable and efficient. While this article gets you started with Flexbox and Grid, I’ll soon publish a more in-depth guide exploring their advanced features, tips, and tricks. Stay tuned for that!



And that’s a wrap on Mastering CSS Basics! I hope you enjoyed reading this as much as I enjoyed writing it. But before we part ways, I’d love to hear from you:



Which CSS layout method do you prefer for your projects—Flexbox or Grid? And why?



Feel free to share your thoughts in the comments below.



Bye for now!!!!

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten CSS Is Not Hard(You 're Just Missing These Basics)- Mastering the Foundation(Part 2)

Thematisch verwandte Begriffe: HardYou, Just, Missing, These · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-94097 | A vulnerability was determined in Netcore NBR200V2 1.3.241127.071246. Th…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick