diff options
| author | Kamal Wickramanayake <kamal@inbox.lk> | 2026-07-04 14:35:25 +0530 |
|---|---|---|
| committer | Kamal Wickramanayake <kamal@inbox.lk> | 2026-07-04 14:35:25 +0530 |
| commit | c3dd2a6d44ef929e0832ce6dca53a818e6711218 (patch) | |
| tree | 66d7254ef8534a0e23b50f9d1fce41cb36a8e6ab /css | |
| parent | 975dccebfcf51878b790a765d8e92ebcad895a24 (diff) | |
Added CSS examples
Diffstat (limited to 'css')
| -rw-r--r-- | css/01-no-css/index.html | 37 | ||||
| -rw-r--r-- | css/02-inline-styling-with-css-properties/index.html | 33 | ||||
| -rw-r--r-- | css/03-embedded-css-utility-classes/index.html | 79 | ||||
| -rw-r--r-- | css/04-external-css/index.html | 33 | ||||
| -rw-r--r-- | css/04-external-css/styles.css | 54 | ||||
| -rw-r--r-- | css/05-classless-css/index.html | 40 | ||||
| -rw-r--r-- | css/06-css-units/images/hulftsdorp.jpg | bin | 0 -> 115681 bytes | |||
| -rw-r--r-- | css/06-css-units/index.html | 111 |
8 files changed, 387 insertions, 0 deletions
diff --git a/css/01-no-css/index.html b/css/01-no-css/index.html new file mode 100644 index 0000000..ef3fc84 --- /dev/null +++ b/css/01-no-css/index.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <title>Retro Styled Pure HTML</title> +</head> +<!-- Sets background color and text color natively via body attributes --> +<body bgcolor="#f0f4f8" text="#2d3748"> + + <!-- Table container used to mimic a centered layout box --> + <table align="center" width="600" bgcolor="#ffffff" cellpadding="20" style="border-collapse: collapse;"> + <tr> + <td> + <!-- Heading with manual alignment --> + <h1 align="center">Retro Native Styling</h1> + <hr color="#e2e8f0" size="1"> + + <p>This layout uses structural tables and attributes to center and color the canvas rather than an external CSS document.</p> + + <!-- Presentational table acting as a decorative callout block --> + <table width="100%" bgcolor="#e6fffa" cellpadding="15"> + <tr> + <td> + <strong>Fun Fact:</strong> This page works identically in a modern browser and a browser from 1996! + </td> + </tr> + </table> + + <p align="right"> + <font size="2" color="#718096">Minimalist footer note</font> + </p> + </td> + </tr> + </table> + +</body> +</html> + diff --git a/css/02-inline-styling-with-css-properties/index.html b/css/02-inline-styling-with-css-properties/index.html new file mode 100644 index 0000000..d59c5ca --- /dev/null +++ b/css/02-inline-styling-with-css-properties/index.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Inline CSS Example</title> +</head> +<body style="background-color: #f4f7f6; font-family: Arial, sans-serif; padding: 20px;"> + + <!-- Styled Heading --> + <h1 style="color: #2c3e50; text-align: center; border-bottom: 2px solid #2c3e50; padding-bottom: 10px;"> + Welcome to My Website + </h1> + + <!-- Styled Paragraph --> + <p style="color: #34495e; font-size: 16px; line-height: 1.6; max-width: 600px; margin: 20px auto;"> + This paragraph is styled using <strong>inline CSS</strong>. The font size, color, line height, and alignment are controlled directly inside the HTML tag via the <code style="background-color: #e0e0e0; padding: 2px 6px; border-radius: 4px;">style</code> attribute. + </p> + + <!-- Styled Call-to-Action Box --> + <div style="background-color: #ffffff; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); padding: 20px; text-align: center; max-width: 400px; margin: 30px auto;"> + <h2 style="color: #e74c3c; margin-top: 0;">Special Offer!</h2> + <p style="color: #7f8c8d;">Get access to exclusive web development content today.</p> + + <!-- Styled Button --> + <button style="background-color: #2ecc71; color: white; border: none; padding: 10px 20px; font-size: 16px; border-radius: 5px; cursor: pointer;"> + Sign Up Now + </button> + </div> + +</body> +</html> + diff --git a/css/03-embedded-css-utility-classes/index.html b/css/03-embedded-css-utility-classes/index.html new file mode 100644 index 0000000..17eb0ba --- /dev/null +++ b/css/03-embedded-css-utility-classes/index.html @@ -0,0 +1,79 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Embedded CSS Example</title> + <style> + /* --- REUSABLE UTILITY CLASSES --- */ + + /* Flexbox center utility */ + .flex-center { + display: flex; + justify-content: center; + align-items: center; + min-height: 100vh; + margin: 0; + font-family: Arial, sans-serif; + background-color: #f4f7f6; + } + + /* Card Component */ + .card { + background-color: #ffffff; + padding: 24px; + border-radius: 8px; + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); + max-width: 400px; + text-align: center; + } + + /* Base Button */ + .btn { + display: inline-block; + padding: 12px 24px; + font-size: 16px; + font-weight: bold; + text-decoration: none; + border-radius: 6px; + border: none; + cursor: pointer; + transition: background-color 0.3s ease; + } + + /* Button Modifiers for Reusability */ + .btn-primary { + background-color: #007bff; + color: #ffffff; + } + + .btn-primary:hover { + background-color: #0056b3; + } + + .btn-secondary { + background-color: #6c757d; + color: #ffffff; + margin-left: 10px; + } + + .btn-secondary:hover { + background-color: #5a6268; + } + </style> +</head> +<body class="flex-center"> + + <div class="card"> + <h2>Welcome Back</h2> + <p>This is a reusable embedded CSS setup. Both buttons below share the base <strong>.btn</strong> rule, but use different modifiers.</p> + + <div style="margin-top: 20px;"> + <a href="#" class="btn btn-primary">Sign In</a> + <a href="#" class="btn btn-secondary">Learn More</a> + </div> + </div> + +</body> +</html> + diff --git a/css/04-external-css/index.html b/css/04-external-css/index.html new file mode 100644 index 0000000..872a05b --- /dev/null +++ b/css/04-external-css/index.html @@ -0,0 +1,33 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Reusable CSS Demo</title> + <!-- Linking the separate CSS file --> + <link rel="stylesheet" href="styles.css"> +</head> +<body> + + <h1>Reusable Components Example</h1> + + <!-- Reusing the .card class and different button variations --> + <div class="card"> + <h2>Product Feature A</h2> + <p>This layout uses the primary action button style.</p> + <button class="btn btn-primary">Accept</button> + </div> + + <div class="card"> + <h2>Product Feature B</h2> + <p>This layout reuses the exact same card wrapper but switches to a secondary button.</p> + <button class="btn btn-secondary">Learn More</button> + </div> + + <div class="card"> + <h2>The beauty of CSS design</h2> + <p>Visit <a href="https://csszengarden.com/" target="_blank">CSS Zen Garden</a> and try changing designs.</p> + </div> +</body> +</html> + diff --git a/css/04-external-css/styles.css b/css/04-external-css/styles.css new file mode 100644 index 0000000..5296453 --- /dev/null +++ b/css/04-external-css/styles.css @@ -0,0 +1,54 @@ +/* 1. Global design tokens (Variables) */ +:root { + --primary-color: #3498db; + --secondary-color: #2ecc71; + --text-dark: #2c3e50; + --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + --border-radius: 8px; +} + +/* 2. Base Element Resets */ +body { + font-family: var(--font-main); + color: var(--text-dark); + line-height: 1.6; + padding: 20px; +} + +/* 3. Reusable Component Classes */ +.card { + border: 1px solid #e0e0e0; + border-radius: var(--border-radius); + padding: 20px; + margin-bottom: 15px; + box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.3); +} + +.btn { + display: inline-block; + padding: 10px 20px; + font-size: 1rem; + font-weight: bold; + text-align: center; + text-decoration: none; + border-radius: var(--border-radius); + border: none; + cursor: pointer; + transition: opacity 0.2s ease; +} + +.btn:hover { + opacity: 0.9; +} + +/* 4. Reusable Modifier Classes */ +.btn-primary { + background-color: var(--primary-color); + color: white; +} + +.btn-secondary { + background-color: var(--secondary-color); + color: white; +} + diff --git a/css/05-classless-css/index.html b/css/05-classless-css/index.html new file mode 100644 index 0000000..6f72bcb --- /dev/null +++ b/css/05-classless-css/index.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Beautiful HTML-Only Page</title> + <!-- The magic line: This automatically styles everything below --> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css"> +</head> +<body> + + <header> + <h1>🚀 Built with Pure HTML</h1> + <p>Zero custom CSS files were written to create this look.</p> + </header> + + <main> + <article> + <h2>Semantic Layouts Work Best</h2> + <p>Classless frameworks look at your semantic HTML tags. They add consistent padding, clean typography, and standard responsive widths automatically.</p> + <p>This page is styled using <a href="https://newcss.net/" target="_blank">new.css</a>.</p> + </article> + + <section> + <h3>Interactive Elements</h3> + <p>Notice how inputs and buttons are automatically styled:</p> + <form action="#"> + <input type="email" placeholder="Enter your email..."> + <button type="submit">Subscribe</button> + </form> + </section> + </main> + + <footer> + <p>© 2026 No-CSS Experiment</p> + </footer> + +</body> +</html> + diff --git a/css/06-css-units/images/hulftsdorp.jpg b/css/06-css-units/images/hulftsdorp.jpg Binary files differnew file mode 100644 index 0000000..ab88942 --- /dev/null +++ b/css/06-css-units/images/hulftsdorp.jpg diff --git a/css/06-css-units/index.html b/css/06-css-units/index.html new file mode 100644 index 0000000..6b6b872 --- /dev/null +++ b/css/06-css-units/index.html @@ -0,0 +1,111 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Modern CSS Units Demo</title> + <style> + /* 1. Root Definition: Using px to establish a base size */ + :root { + font-size: 16px; /* Base size for root (1rem = 16px) */ + } + + /* Reset and Box Sizing */ + * { + box-sizing: border-box; + margin: 0; + padding: 0; + } + + body { + font-family: Arial, sans-serif; + color: #333; + } + + /* 2. Viewport Height & Width: vh, vw */ + .hero { + height: 80vh; /* Takes up 80% of the viewport height */ + width: 100vw; /* Takes up 100% of the viewport width */ + background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + text-align: center; + color: white; + padding: 2rem; + } + + /* 3. Root em (rem): rem for scalable typography */ + .hero h1 { + font-size: 3rem; /* 3 x 16px = 48px */ + margin-bottom: 1rem; /* 1 x 16px = 16px */ + } + + .hero p { + font-size: 1.25rem; /* 1.25 x 16px = 20px */ + max-width: 60ch; /* Limits the width to about 60 characters for readability */ + } + + /* 4. Content Area */ + .content { + padding: 3rem 5%; /* Padding utilizes rem and percentage */ + max-width: 1200px; /* Absolute max-width constraint */ + margin: 0 auto; + } + + /* 5. Em unit: em for element-specific relative sizing */ + .card { + background-color: #f9f9f9; + border: 1px solid #ddd; + padding: 2em; /* Padding is relative to the card's own font-size */ + margin-bottom: 2rem; + border-radius: 0.5em; /* Border radius scales with the card's font */ + } + + .card h2 { + font-size: 2em; /* 2 x card base font-size */ + margin-bottom: 0.5em; + } + + .card p { + font-size: 1em; /* Matches the card base font-size */ + line-height: 1.6; + } + + /* 6. Percentage (%) and Pixels (px) */ + .image-container { + width: 100%; /* Takes 100% of the parent card's width */ + max-width: 400px; /* Max width constraint in pixels */ + margin: 1rem auto 0 auto; + } + + .image-container img { + max-width: 100%; + height: auto; + border-radius: 8px; /* Strict absolute unit for rounding */ + display: block; /* Removes unwanted baseline spacing */ + } + </style> +</head> +<body> + + <div class="hero"> + <h1>Responsive Layout with CSS Units</h1> + <p>This section uses <strong>vh</strong> for height and <strong>vw</strong> for width. The typography uses <strong>rem</strong> and <strong>ch</strong>.</p> + </div> + + <div class="content"> + <div class="card"> + <h2>The Card Heading</h2> + <p>This card's padding and margins scale relative to its own font-size using the <strong>em</strong> unit. The card width is controlled by percentages and absolute pixels.</p> + <div class="image-container"> + <!-- Using percentage and px for sizing --> + <a href="https://www.adhikarana.org/" target="_blank"><img src="images/hulftsdorp.jpg" alt="Hulftsdorp, Colombo"> + </div> + </div> + </div> + +</body> +</html> + |
