<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Duminda Gayan Kodagoda on Medium]]></title>
        <description><![CDATA[Stories by Duminda Gayan Kodagoda on Medium]]></description>
        <link>https://medium.com/@duminda.g.k?source=rss-de7d3f4c57df------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IiZOKTnuoKn_eNAsAfroPA.jpeg</url>
            <title>Stories by Duminda Gayan Kodagoda on Medium</title>
            <link>https://medium.com/@duminda.g.k?source=rss-de7d3f4c57df------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 16:20:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@duminda.g.k/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Seedr]]></title>
            <link>https://medium.com/@duminda.g.k/seedr-78534f9b56c8?source=rss-de7d3f4c57df------2</link>
            <guid isPermaLink="false">https://medium.com/p/78534f9b56c8</guid>
            <dc:creator><![CDATA[Duminda Gayan Kodagoda]]></dc:creator>
            <pubDate>Wed, 25 Jun 2025 18:43:57 GMT</pubDate>
            <atom:updated>2025-06-25T18:43:57.723Z</atom:updated>
            <content:encoded><![CDATA[<p>The Easiest Way to Stream, Download, and Enjoy Content Anywhere!</p><p>As a tech enthusiast and frequent content consumer, I’m always looking for tools that make life easier, faster, and more accessible. One tool I stumbled upon — and now can’t live without — is <strong>Seedr</strong>.</p><p>If you’ve ever struggled with torrent clients, slow downloads, device compatibility issues, or security concerns, <strong>Seedr</strong> is the solution you’ve been waiting for. It’s a <em>cloud-based torrent client</em> that eliminates all the hassles of traditional downloading.</p><h3>⚡ What Makes Seedr So Good?</h3><h4>1. No Software Needed</h4><p>Seedr runs entirely in your browser. That’s right — no installations, no third-party apps, no popups. Just paste a magnet link or .torrent file, and Seedr does the rest in the cloud. Fast, clean, and secure.</p><h4>2. Stream Instantly with SeedrPlay</h4><p>This is by far my favourite feature. Once a file is downloaded, you don’t even need to transfer it to your device. Seedr lets you <em>watch movies</em>, <em>listen to music</em>, or <em>read PDFs and eBooks</em> — all <strong>online</strong>, without taking up space on your device.</p><p>Whether I’m on my laptop at home, my phone during commutes, or my tablet while travelling, I can access everything through Seedr’s sleek and responsive web interface.</p><h3>📱 Device Freedom</h3><p>Seedr works seamlessly across all my devices. There’s no limit to what I can access — and no difference in experience. It’s like having my own personal media center in the cloud that’s always synced and available, no matter where I am.</p><ul><li>Watching a documentary on my phone while waiting in line? ✅</li><li>Listening to a music album I downloaded last night? ✅</li><li>Streaming a 4K movie on my laptop without downloading it? ✅</li></ul><h3>🔐 Safe, Private &amp; Fast</h3><p>Seedr isn’t just convenient — it’s <strong>secure</strong>. It downloads content directly from the torrent network using its servers, keeping your identity safe and your IP hidden. No more worrying about trackers, seeders, or bandwidth throttling.</p><p>Plus, downloads are lightning fast. Seedr uses high-speed servers, so popular torrents are fetched almost instantly. It’s like magic.</p><h3>💡 Why I Recommend Seedr</h3><p>As a blogger, freelancer, and everyday digital user, Seedr has streamlined how I manage content. It saves time, protects my privacy, and gives me a simple way to access everything I need — when I need it.</p><p>If you haven’t tried Seedr yet, I highly recommend it. It’s perfect for students, digital nomads, media junkies, or anyone tired of the old way of downloading. Just upload, stream, and enjoy — <em>no strings attached</em>.</p><p>Visit <a href="https://www.seedr.cc/">https://www.seedr.cc</a> and give it a try. Trust me, once you experience the freedom of Seedr, you’ll never go back.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78534f9b56c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[1. Min, max and clamp]]></title>
            <link>https://medium.com/@duminda.g.k/15-modern-css-features-3ba58c8b329d?source=rss-de7d3f4c57df------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ba58c8b329d</guid>
            <dc:creator><![CDATA[Duminda Gayan Kodagoda]]></dc:creator>
            <pubDate>Fri, 20 Jun 2025 13:29:15 GMT</pubDate>
            <atom:updated>2025-06-20T13:37:22.045Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q2RfRCGxqXCaY376b0VCpQ.png" /></figure><p><strong>min()</strong> picks the smaller value, <strong>max()</strong> picks the larger value, <strong>clamp()</strong> combines both with a fluid middle value that scales between set minimum and maximum limits.</p><pre>/* Chooses the smaller of two values */<br>.cart-button {<br>  width: min(300px, 90%);<br>}</pre><p>90% is used as long as it remains under 300px; once it exceeds 300px, the value defaults to 300px. It’s a common pattern for making buttons that look good on both desktop and mobile devices without needing media queries.</p><pre>/* Choosing the larger of two values */<br>.main-container {<br>  font-size: max(16px, 1.2vw);<br>}</pre><p>max() picks the larger value, so elements don’t get too small. In the example, text grows on bigger screens but never goes below 16px, which helps keep it readable and accessible.</p><pre>.main-title {<br>  font-size: clamp(1.5rem, 5vw, 3rem);<br>}</pre><p>clamp() combines min() and max() — it takes a minimum, a preferred, and a maximum value. In the example, clamp() sets a fluid font size that scales with viewport width (5vw) but never goes below 1.5rem or above 3rem.</p><p><strong>Browsers Support: </strong><a href="https://caniuse.com/?search=Min%2C%20max%20and%C2%A0clamp">https://caniuse.com/?search=Min%2C%20max%20and%C2%A0clamp</a></p><h3>2. Container queries</h3><p>Container queries make elements respond to their parent container’s size instead of the viewport width</p><pre>/* Step 1: Mark the parent as a containment context */<br>.cards {<br>  container-type: inline-size;<br>}<br><br>/* Step 2: Base styles for the card component */<br>.card {<br>  display: flex;<br>  flex-direction: column;<br>  gap: .5rem;<br>}<br><br>/* Step 3: Layout changes based on container width */<br>@container (width &gt; 200px) {<br>  .card {<br>    flex-direction: row;<br>    align-items: center;<br>    justify-content: space-between;<br>  }<br>}</pre><p><strong>Browsers Support: </strong><a href="https://caniuse.com/?search=Container%20queries">https://caniuse.com/?search=Container%20queries</a></p><h3>3. text-wrap: balance &amp; pretty</h3><p>This controls how text wraps to make it easier to read. balance evens out line lengths, while pretty avoids leaving a single word on the last line</p><pre>/* ideal for headings */<br>.section-title {<br>  text-wrap: balance;<br>  /*<br>    Welcome to<br>    our Platform<br>    --becomes---<br>    Welcome to our<br>    Platform<br>  */<br>}</pre><pre>/* ideal for paragraphs */<br>.card-description {<br>  text-wrap: pretty;<br>  /* <br>    This is a long description about<br>    features<br>    --becomes---<br>    This is a long description<br>    about features<br>   */<br>}</pre><p><strong>Browsers Support: </strong><a href="https://caniuse.com/?search=text-wrap%3A%20balance%3B">https://caniuse.com/?search=text-wrap%3A%20balance%3B</a> , <a href="https://caniuse.com/?search=text-wrap%3A%20pretty%3B">https://caniuse.com/?search=text-wrap%3A%20pretty%3B</a></p><h3>4. CSS Relative Color Syntax</h3><p>The from syntax lets you create new colors based on existing ones by extracting their components and applying math operations. It&#39;s useful for creating color variations and dynamic themes.</p><pre>.button {<br>  --brand: #FF0000; /* red */<br>  color: #0000FF; /* blue */<br><br>  background: hsl(from currentColor h s l);<br>  background: rgb(from var(--brand) r g b);<br>  background: hsl(from #0000FF calc(h + 60) calc(s * 0.8) calc(l * 1.2)); /* Takes blue (h=240deg s=100% l=50%) and transforms it into h=300deg s=80% l=60% (purple-like) */<br>}</pre><p><strong>Color Extraction:</strong></p><ul><li>hsl(from currentColor h s l) - extracts hue, saturation, lightness from the blue text color. (h=240deg s=100% l=50%)</li><li>rgb(from var(--brand) r g b) - extracts red, green, blue values from the red custom property. (r=255 g=0 b=0)</li></ul><p><strong>Color Transformation:</strong></p><ul><li>hsl(from #0000FF calc(h + 60) calc(s * 0.8) calc(l * 1.2)) - takes blue and transforms it:</li><li>Shifts hue by 60° (blue → purple)</li><li>Reduces saturation to 80%</li><li>Increases lightness to 120%</li></ul><p>blue (h=240deg s=100% l=50%) transformed into purple-like(h=300deg s=80% l=60%)</p><p><strong>Browsers Support: </strong><a href="https://caniuse.com/?search=CSS%20Relative%20color%20syntax">https://caniuse.com/?search=CSS%20Relative%20color%20syntax</a></p><h3>5. Margin Block/Inline Properties</h3><p>The margin-block, margin-inline, padding-block, and padding-inline properties were introduced as a more flexible alternative to the traditional top, right, bottom, and left properties.</p><pre>/* Traditional directional properties */<br>.card {<br>  margin-top: 1rem;<br>  margin-bottom: 1rem;<br><br>  padding-right: 1.25rem;<br>  padding-left: 1.25rem;<br>}</pre><pre>/* Modern block/inline properties */<br>.card {<br>  margin-block: 1rem; /* top and bottom */<br>  margin-block-start: 1rem;<br>  margin-block-end: 2rem;<br><br>  padding-inline: 1.25rem; /* left and right */<br>  padding-inline-start: 1rem;<br>  padding-inline-end: 2rem;<br>}</pre><p>These properties automatically adapt to different writing modes (horizontal/vertical) and text directions (RTL/LTR), while reducing CSS code by combining directional properties.</p><p><strong>Browsers Support: </strong><a href="https://caniuse.com/?search=margin-block">https://caniuse.com/?search=margin-block</a> , <a href="https://caniuse.com/?search=padding-block">https://caniuse.com/?search=padding-block</a></p><h3>6. @starting-style</h3><p>Use the new @starting-style rule to smoothly animate elements that start with display: none by changing opacity</p><pre>.modal {<br>  display: none;<br>  opacity: 1;<br>}<br><br>.modal.open {<br>  display: block;<br>  transition: opacity 300ms;<br>  opacity: 1;<br>}<br><br>/* Define starting styles when modal becomes displayed */<br>@starting-style {<br>  .modal.open {<br>    opacity: 0;<br>  }<br>}</pre><p><strong>Browsers Support: </strong><a href="https://caniuse.com/?search=%40starting-style">https://caniuse.com/?search=%40starting-style</a></p><h3>7. :has()</h3><p>Enables selecting a parent element based on its child elements — something that wasn’t possible in CSS before.</p><pre>/* Card changes style if it contains an error message */<br>.card:has(.error-message) {<br>  border-color: red;<br>  background: rgb(255 0 0 / .05);<br>}</pre><pre>/* Form groups that have required inputs */<br>.form-group:has(input[required]) {<br>  /* Show required indicator */<br>  &amp;::before {<br>    content: &quot;*&quot;;<br>    color: red;<br>  }<br>}</pre><p><strong>Browsers Support: </strong><a href="https://caniuse.com/?search=%3Ahas()">https://caniuse.com/?search=%3Ahas()</a></p><h3>8. Media Query Ranges</h3><p>A cleaner way to define min/max ranges in media queries using comparison operators, replacing the longer min-width and max-width syntax.</p><pre>/* Old syntax */<br>@media (min-width: 768px) and (max-width: 1199px) {<br>  .card { width: 65ch; }<br>}<br><br>/* New range syntax */<br>@media (768px &lt;= width &lt;= 1199px) {<br>  .card { width: 65ch; }<br>}</pre><pre>/* Common breakpoint pattern with css nesting */<br>.container {<br>  @media (width &lt; 768px) {<br>    padding: 1rem;<br>  }<br><br>  @media (width &gt;= 1200px) {<br>    max-width: 1140px;<br>  }<br><br>  @media (480px &lt;= width &lt; 768px) {<br>    margin: 1.5rem;<br>  }<br>}</pre><p><strong>Browsers Support: </strong><a href="https://caniuse.com/?search=Media%20Queries%3A%20Range%20Syntax">https://caniuse.com/?search=Media%20Queries%3A%20Range%20Syntax</a></p><h3>9. light-dark</h3><p>A shorthand to apply styles based on the user’s color scheme preference, without needing separate media queries.</p><pre>.card {<br>  background: light-dark(#f1f5f9, #0f172a);<br>  color: light-dark(#0f172a, #f1f5f9);<br>  border: 1px solid light-dark(rgb(226, 232, 240), rgb(51, 65, 85));<br>  /* Works with any color format */<br>}</pre><p><strong>Browsers Support: </strong><a href="https://caniuse.com/?search=light-dark">https://caniuse.com/?search=light-dark</a></p><h3>10. color-scheme</h3><p>Used alongside light-dark, the color-scheme property tells the browser which themes a component supports, so built-in elements like scrollbars and form inputs automatically match the user&#39;s preference.</p><pre>/* Global level*/<br>:root {<br>  /* Support both schemes, dark listed first means dark is preferred */<br>  color-scheme: dark light;<br>}<br><br>/* Component level */<br>.card {<br>  /* This card only supports light mode and Inner elements will stay light */<br>  color-scheme: light;<br><br>  input {<br>    /* Inputs remain light-styled even in dark mode */<br>    border: 1px solid #ddd;<br>  }<br>}<br><br>/* Component level */<br>.code {<br>  /* Force dark appearance for all system UI within */<br>  color-scheme: dark;<br>}</pre><p><strong>Browsers Support: </strong><a href="https://caniuse.com/?search=color-scheme">https://caniuse.com/?search=color-scheme</a></p><h3>11. Nesting</h3><p>Borrowed from preprocessors like Less and Sass, native CSS now supports nesting child selectors inside parent selectors. This makes the structure clearer by directly showing the relationship between components and their children — something that previously relied on naming conventions like BEM (e.g., card__header).</p><pre>/* Without nesting */<br>.parent {<br>  /* parent body */<br>}<br>.parent .child {<br>  /* child body */<br>}</pre><pre>/* Withnesting */<br>.parent {<br>  /* parent body */<br><br>  &amp;:hover {<br>    /* on parent hover */<br>  }<br><br>  @media (width &gt; 768px) {<br>    /* media query on parent */<br>  }<br><br>  /* without nesting selector*/<br>  .child {<br>   /* child body */<br>  }<br><br>  /* with nesting selector */<br>  &amp; .child {<br>    /* child body */<br>  }<br><br>  &amp; .child1,<br>  &amp; .child2 {<br>    /* multiple children */<br>  } <br><br>}</pre><p><strong>Browsers Support: </strong><a href="https://caniuse.com/?search=Nesting">https://caniuse.com/?search=Nesting</a></p><h3>12. Units</h3><p>CSS units are either absolute (like cm, mm, in) or relative (like px, em, vw). While absolute units are fixed, relative units scale based on factors like font size or viewport. Over time, CSS has introduced more flexible units — em for fonts, vw/vh for viewports, and dvh for better mobile support. Some units behave differently depending on the property they’re used with, such as font-size vs. margin.</p><p><strong>Font Based</strong></p><ul><li>em — Relative to the parent element’s font size</li><li>rem — Relative to the root element’s font size</li><li>ex — Represents the x-height of the current font (roughly the height of lowercase “x”)</li><li>ch — Width of the “0” (zero) character in the current font</li><li>lh — Equal to the line-height of the element</li></ul><p><strong>Viewport-based</strong></p><ul><li>vh — 1% of the viewport height</li><li>vw — 1% of the viewport width</li><li>vmin — 1% of the viewport’s smaller dimension (height or width)</li><li>vmax — 1% of the viewport’s larger dimension (height or width)</li></ul><p><strong>Modern viewport</strong></p><ul><li>dvh — Dynamic viewport height, adjusts for mobile browser chrome/UI elements</li><li>dvw — Dynamic viewport width</li><li>svh — Small viewport height, smallest possible height when accounting for dynamic UI elements</li><li>svw — Small viewport width</li><li>lvh — Large viewport height, largest possible height when accounting for dynamic UI elements</li><li>lvw — Large viewport width</li></ul><p><strong>Browsers Support:</strong> <a href="https://caniuse.com/?search=Units">https://caniuse.com/?search=Units</a></p><h3>13. @layer</h3><p>Similar to Tailwind CSS, @layer lets you control style priority by ordering groups—later layers override earlier ones, helping avoid confusing specificity issues.</p><pre>/* Define layer order - order here determines priority */<br>@layer reset, components, utilities;<br><br>/* Reset layer: lowest priority */<br>@layer reset {<br>  * {<br>    margin: 0;<br>    padding: 0;<br>    box-sizing: border-box;<br>  }<br>}<br><br>/* Components layer: middle priority */<br>@layer components {<br>  .button {<br>    /* Even if utilities have lower specificity,<br>       they&#39;ll still override these styles */<br>    padding: .5rem 1rem;<br>    background: blue;<br>  }<br>}<br><br>/* Utilities layer: highest priority */<br>@layer utilities {<br>  .p-4 {<br>    /* This wins over component padding */<br>    padding: 1.25rem;<br>  }<br><br>  .bg-red {<br>    /* This wins over component background */<br>    background: red;<br>  }<br>}</pre><p><strong>Browsers Support:</strong> <a href="https://caniuse.com/?search=%40layer">https://caniuse.com/?search=%40layer</a></p><h3>14. :where() and :is()</h3><p>Use :is() for normal styling, :where() when you want styles that are easily overridden.</p><p>:is() - <strong>Maintains specificity</strong></p><pre>/* These two selectors are equivalent: */<br>:is(h1, h2, h3) { color: blue; }<br>h1, h2, h3 { color: blue; }<br><br>/* These two selectors are equivalent: */<br>:is(.card, .panel) :is(h1, h2) {<br> font-weight: bold;<br>}<br>.card h1, .card h2, .panel h1, .panel h2 {<br> font-weight: bold;<br>}</pre><p>:where() - <strong>Zero specificity</strong></p><pre>/* Low specificity - easy to override */<br>:where(h1, h2, h3) { color: blue; }<br><br>/* This will override the above because it has higher specificity */<br>h1 { color: red; }</pre><p><strong>Key Difference — Specificity Battle</strong></p><pre>/* :is() has normal specificity (0,1,1) */<br>:is(.highlight) p { color: blue; }<br><br>/* :where() has zero specificity (0,0,0) */<br>:where(.highlight) p { color: red; }<br><br>/* Simple element selector wins over :where() */<br>p { color: green; } /* This wins over :where() */<br><br>/* But loses to :is() */<br>.highlight p { color: blue; } /* This is what actually displays */</pre><p><strong>Practical Use Cases</strong></p><pre>/* :where() for default styles that are easy to override */<br>:where(button, input[type=&quot;button&quot;]) {<br>  padding: 8px 16px;<br>  border-radius: 4px;<br>}<br><br>/* :is() for component variations */<br>.card :is(h1, h2, h3, h4, h5, h6) {<br>  margin-top: 0;<br>}</pre><p><strong>Note: Specificity Hierarchy (from highest to lowest)</strong></p><ol><li><strong>Inline styles</strong> — style=&quot;color: red&quot; (1,0,0,0)</li><li><strong>IDs</strong> — #header (0,1,0,0)</li><li><strong>Classes, attributes, pseudo-classes</strong> — .button, [type=&quot;text&quot;], :hover (0,0,1,0)</li><li><strong>Elements and pseudo-elements</strong> — div, ::before (0,0,0,1)</li></ol><h3>15. Use of Color functions</h3><p>CSS color functions provide advanced ways to define and manipulate colors beyond basic hex codes and named colors. we can use modern color functions like hsl(), lab(), lch(), oklch() for better color spaces</p><p><strong>Traditional Color Functions<br></strong>RGB/RGBA, HSL/HSLA</p><pre>.card{<br>  color: rgb(255, 0, 0);        /* Red */<br>  color: rgba(255, 0, 0, 0.5);  /* Semi-transparent red */<br>  color: hsl(240, 100%, 50%);     /* Blue */<br>  color: hsla(240, 100%, 50%, 0.8); /* Semi-transparent blue */<br>}</pre><p><strong>Modern Color Functions<br></strong>HWB (Hue, Whiteness, Blackness)<br>LAB/LCH — Perceptually Uniform Color Spaces<br>OKLCH/OKLAB — Improved Perceptual Uniformity</p><pre>.card{<br>  color: hwb(240 20% 30%);  /* Blue with 20% white, 30% black mixed in */<br>  color: lab(50% 20 -30);    /* LAB: Lightness, A-axis, B-axis */<br>  color: lch(50% 40 240);    /* LCH: Lightness, Chroma, Hue */<br>  color: oklch(70% 0.15 180); /* Better than LCH for gradients */<br>  color: oklab(70% -0.1 0.05); /* Better than LAB */<br>}</pre><p><strong>Color Manipulation Functions</strong></p><pre>.card{<br>/* Mix two colors using color-min function */<br>color: color-mix(in srgb, red 30%, blue 70%);<br>color: color-mix(in oklch, var(--primary) 80%, white 20%);<br><br>/* Modify existing colors using realative color syntax */<br>color: hsl(from blue h s calc(l * 0.8));        /* Darker blue */<br>color: oklch(from var(--brand) l c calc(h + 60)); /* Shift hue */<br>}</pre><p><strong>Practical Examples</strong></p><p>Dynamic Color Schemes</p><pre>:root {<br>  --primary: oklch(60% 0.2 240);<br>}<br><br>.button {<br>  background: var(--primary);<br>  border: 2px solid oklch(from var(--primary) calc(l * 0.8) c h);<br>}<br><br>.button:hover {<br>  background: color-mix(in oklch, var(--primary) 80%, white 20%);<br>}</pre><p>Better Gradients</p><pre>/* OKLCH prevents muddy colors in gradients */<br>background: linear-gradient(<br>  to right,<br>  oklch(70% 0.15 0),      /* Red */<br>  oklch(70% 0.15 120),    /* Green */<br>  oklch(70% 0.15 240)     /* Blue */<br>);</pre><h4>Why Use Modern Color Functions?</h4><ul><li><strong>Better gradients</strong> — No muddy colors</li><li><strong>Consistent lightness</strong> — Colors appear equally bright</li><li><strong>Easy manipulation</strong> — Lighten, darken, shift hue programmatically</li><li><strong>Future-proof</strong> — Support for wider color gamuts (P3, Rec2020)</li></ul><p>The OKLCH color space is particularly powerful for creating harmonious color schemes and smooth gradients.</p><h3>* Other useful modern CSS features</h3><ul><li><strong>CSS Grid</strong> — Two-dimensional layout system</li><li><strong>Flexbox</strong> — One-dimensional flexible layouts</li><li><strong>Subgrid</strong> — Grid items that inherit parent grid structure</li><li><strong>:focus-visible</strong> - Better focus indication for accessibility</li><li><strong>aspect-ratio</strong> - Easily maintain consistent width-to-height ratios</li><li><strong>accent-color</strong> - Quickly theme form controls like checkboxes and radio buttons.</li><li><strong>prefers-reduced-motion</strong> - Respects user preferences for reduced animation.</li><li><strong>CSS Anchor Positioning</strong> — Position elements relative to other elements</li><li><strong>Scroll-driven animations</strong> — Animations triggered by scroll position</li><li><strong>View Transitions API</strong> — Smooth page transitions</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ba58c8b329d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shorten Text with ellipsis (…)]]></title>
            <link>https://medium.com/@duminda.g.k/shorten-text-with-ellipsis-e0eb1e214774?source=rss-de7d3f4c57df------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0eb1e214774</guid>
            <dc:creator><![CDATA[Duminda Gayan Kodagoda]]></dc:creator>
            <pubDate>Thu, 02 Mar 2023 11:04:53 GMT</pubDate>
            <atom:updated>2023-03-02T11:12:20.836Z</atom:updated>
            <content:encoded><![CDATA[<h3>[CSS] Shorten Text with <em>ellipsis (…)</em></h3><p>You can use line-clamp for that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D8laD8yaiIQBpLQUwpt-wQ.png" /></figure><pre>.line_clamp{<br>  display: -webkit-box;<br>  -webkit-line-clamp: 4;<br>  -webkit-box-orient: vertical;<br>  overflow: hidden;<br>  text-overflow: ellipsis;<br>}</pre><p>You can decide the number of visible lines by <strong>line-clamp</strong></p><p>You can check the browser compatibility here. which is amazing right now.<br><a href="https://caniuse.com/?search=line-clamp">https://caniuse.com/?search=line-clamp</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FSachin901%2Fembed%2Fpreview%2FBaOWqyo%3Fdefault-tabs%3Dcss%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DBaOWqyo&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2FSachin901%2Fpen%2FBaOWqyo&amp;image=https%3A%2F%2Fshots.codepen.io%2FSachin901%2Fpen%2FBaOWqyo-512.jpg%3Fversion%3D1677754006&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a704b7067260d14ec9e0cdb97456b65/href">https://medium.com/media/0a704b7067260d14ec9e0cdb97456b65/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0eb1e214774" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Common CSS Bugs and How to Fix Them]]></title>
            <link>https://medium.com/@duminda.g.k/css-common-bugs-fixes-b2a7cb1538da?source=rss-de7d3f4c57df------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2a7cb1538da</guid>
            <dc:creator><![CDATA[Duminda Gayan Kodagoda]]></dc:creator>
            <pubDate>Sat, 05 Nov 2022 13:04:45 GMT</pubDate>
            <atom:updated>2022-11-17T18:39:41.259Z</atom:updated>
            <content:encoded><![CDATA[<p>There are CSS properties that must be used with care. If not, it can result in bugs and odd behaviours.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*yFtX33qzlI6WmBrZiAFTiQ.png" /></figure><p><strong>Topic : Vertical Padding or margin of inline elements</strong></p><pre>span { <br>  padding-top: 1rem;<br>  padding-bottom: 1rem;<br>  margin-top: 1rem;<br>  margin-bottom: 1rem;<br>}</pre><p><strong>The vertical margin,</strong> or <strong>padding,</strong> does not affect <strong>inline</strong> elements such as span. We must convert them to either <strong>inline-block</strong> or <strong>block</strong> elements.</p><pre>span {<br>  display: inline-block;<br>  ...<br>}</pre><p>Note: However, horizontal margins and paddings still work with inline elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*WCChE0XXzrVDk13wVj66gg.png" /></figure><p><strong>Topic : z-index without position</strong></p><p>The z-index property won’t work if the <strong>position</strong> value is not there. It needs a position value other than static.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*iHD3XLSz73u9zocJUBaDYQ.png" /></figure><p><strong>Topic : Overriding One Property With Another</strong></p><pre>.element {<br> width: 500px;<br> min-width: 50%;<br> max-width: 100%;<br>}</pre><p>If the element’s width exceeds 500px, it will be 50% of its parent’s width. It will take up the entirety of its parent if it is less than 500px. To comprehend how the width property operates, please refer to the following example.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FSachin901%2Fembed%2Fpreview%2FoNyzNXm%3Fdefault-tabs%3Dcss%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DoNyzNXm&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2FSachin901%2Fpen%2FoNyzNXm&amp;image=https%3A%2F%2Fshots.codepen.io%2FSachin901%2Fpen%2FoNyzNXm-512.jpg%3Fversion%3D1667647298&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/10c8d7535f82f9efd12c98515f10a2d4/href">https://medium.com/media/10c8d7535f82f9efd12c98515f10a2d4/href</a></iframe><pre>.card {<br> height: 300px;<br> width: 300px;<br> background-color: black;<br>background: red url (&quot;test.png&quot;) no-repeat right top;<br>}</pre><p>In the preceding example, the background property takes precedence over the background-color property. To resolve the issue, change the order or use only the background shorthand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*vSDRocZKkQnOifgMXLeMqQ.png" /></figure><p><strong>Topic : Typo in a CSS Property’s name</strong></p><pre>.card {<br>  display: flax;<br>}</pre><p>When something goes wrong, CSS doesn’t throw an error. The browser’s DevTools can help you figure out what’s wrong. This is how the error will appear in DevTools</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*9qkerLQ0L65KL_oemJCqQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*sQdjZUfa45VlX52BWjE4iQ.png" /></figure><p><strong>Topic : Using invalid values</strong></p><pre>.element{<br>  opacity: 50;<br>}</pre><p>Values for opacity can range from 0 to 1, or be expressed as a percentage. If you enter a value that the browser doesn’t recognize, it will disregard it. In order to properly implement CSS, we require knowledge of all permitted values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*e0QkKHlJj6EGwapaLlredA.png" /></figure><p><strong>Topic : Duplication of properties</strong></p><pre>.card {<br>  display: flex;<br>  align-items: center;<br>  justify-content: center;<br>  width: 300px;<br>  height: 600px;<br>  display: block;<br>}</pre><p><strong>display: block</strong> has overridden the <strong>display: flex</strong> value. You can figure it out using the browser’s DevTools.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*SnvZ1aOqzEzQyj4yTBorVA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*m11S6FmLs8gLxUskNyTQYw.png" /></figure><p><strong>Topic : Overridden by Cascading behavior of CSS</strong></p><pre><a href="http://twitter.com/media">@media</a> screen and (min-width: 480px) {<br>  .element {<br>    background-color: red;<br>  }<br>}</pre><pre>.element {<br>  height: 300px;<br>  width: 300px;<br>  background-color: black;<br>}</pre><p>The element in the preceding example will always be black. The reason for this is the CSS’s cascading behavior, which means the latter will take precedence over the former.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*lUWrCQATwNVcD1lF3658_g.png" /></figure><p><strong>Topic : Cache issues</strong></p><p>Due to browser caching, sometimes expected changes are not visible. To view changes, clear the browser’s cache and perform a hot reload, or add a query string. The version number can be increased to &quot;Bust the Cache.&quot;</p><pre>&lt;link rel=&quot;stylesheet&quot; href=&quot;style.css?v=1.0.0&quot;&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*6xEqmKnk1KrRrCyfuFgNPA.png" /></figure><p><strong>Topic : Using the wrong property for animation</strong></p><pre>.element:hover{<br>  left: 100px;<br>}</pre><p>The UX of an interface can be substantially enhanced by animations, but it’s crucial to follow some rules to avoid overdoing it. The <strong>left</strong> property is a performance killer because it forces the browser to repaint the layout for every pixel that is moved. In such a case, you can use the <strong>transform</strong> property without impacting performance.</p><pre>.element:hover{<br>  transform: translateX(100px);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*9sclWnNEqJphzOOMLLprFg.png" /></figure><p><strong>Topic : Specificity issues</strong></p><pre>.title {<br>  color: red;<br>}</pre><pre>.card .title {<br>  color: green;<br>}</pre><p><strong>card.title</strong> has a greater specificity than <strong>title</strong>. As a result, the former would be overridden. To fix this, try to always use variant classes</p><pre>.card-title {<br>  color: green;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eeKbhHvPs568yLqwTP_4XA.png" /><figcaption>How to calculate specificity</figcaption></figure><p>Note: Because it is difficult to maintain CSS on a large scale, use !important only when absolutely necessary. If you want to use !important, place it closer to the DOM’s leaf nodes.</p><p>Note: Use inline CSS styles only when absolutely necessary. Since <strong>inline CSS</strong> has a higher level of specificity than a rule in a CSS file, we will be forced to use an <strong>!important</strong> rule unnecessarily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*FYZbIsXBBR1zl-7MhSQggQ.png" /></figure><p><strong>Topic : Normalization not used</strong></p><p>To make browsers render all elements more consistently, we must begin with normalization. You can use n<a href="https://necolas.github.io/normalize.css/">ormalize.css</a> for this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*6s1cAljBpiTfYjpPmQpyLQ.png" /></figure><p><strong>Topic : Body has default margin</strong></p><pre>body {<br>  margin: 0;<br>}</pre><p>Note: If you are using normalize.css, then this will be automatically added.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*SEe7Pr4ga0TFlsz7TfOu5w.png" /></figure><p><strong>Topic : Issues with floats</strong></p><p>We should know the following about float:</p><ul><li>Floated items should always have a width (except if applied directly to an image — which has implicit width). The results can be unpredictable if no width is specified.</li><li>Floated boxes <strong>will move to the left or right</strong> until their outer edge touches the containing block edge or the outer edge of another float.</li><li>A floated box is an element that is taken out of normal flow, so all other elements still within normal flow will ignore it completely and not make room for it.</li><li>If this parent element only contained floated elements, its height would literally collapse to zero.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A3NvuJQMv06InojMK67ClQ.png" /></figure><ul><li>Use <strong>.clearfix</strong> class on the parent element to prevent unpredictable behaviors in the normal flow of elements.</li></ul><pre>.clearfix::after {<br>  content: &quot;&quot;;<br>  clear: both;<br>  display: table;<br>}</pre><p>The following examples demonstrate how to use clearfix hack</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FSachin901%2Fembed%2Fpreview%2FPoaGodb%3Fdefault-tabs%3Dhtml%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DPoaGodb&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2FSachin901%2Fpen%2FPoaGodb&amp;image=https%3A%2F%2Fshots.codepen.io%2FSachin901%2Fpen%2FPoaGodb-512.jpg%3Fversion%3D1667689171&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d0a81a11638a92a5d5b01dfa580925b/href">https://medium.com/media/9d0a81a11638a92a5d5b01dfa580925b/href</a></iframe><ul><li>If <strong>float</strong> is applied to an element, the browser will render it as a block-level element.</li></ul><pre>img { <br>  float: left; <br>  /* This became a block element */<br>}</pre><ul><li>Float will not work when the display type is flex or inline flex.</li></ul><pre>.element { <br>  display: flex;<br>  float: left; /* Has no effect! */ <br>}</pre><ul><li>Note: Today, we have much more robust tools for creating web page layouts. Namely, Flexbox and Grid. Floats are still important to understand because they possess some abilities that are unique to them.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*kCNEGeRPszDuNzgJ5nVVKA.png" /></figure><p><strong>Topic : No Browser Support</strong></p><p>There are CSS features that are not supported by browsers or have limited browser support. <a href="https://caniuse.com/"><strong>Can I Use</strong></a> is an extremely useful tool for determining browser compatibility. You may use vendor prefixes, but they are also unrefined, experimental web features with potential side effects. <a href="https://autoprefixer.github.io/"><strong>Autoprefixer</strong></a> is an online tool that can be used to prefix your code.</p><p>Prefixes for all major browsers:</p><ul><li>-webkit-: Chrome; Safari; recent versions of Opera; almost all iOS browsers, including Firefox for iOS; basically, any WebKit-based browser</li><li>-moz- : Firefox</li><li>-o- : old pre-WebKit versions of Opera</li><li>-ms- : Internet Explorer and Microsoft Edge</li></ul><pre>.example {<br> -webkit-transition: all 4s ease;<br> -o-transition: all 4s ease;<br> transition: all 4s ease;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*flrpYrUISzawD1sA5D8boQ.png" /></figure><p><strong>Topic : </strong>Improper box-sizing</p><p>The box-sizing property specifies how an element’s total width and height are calculated. By default, an element’s width and height are only assigned to the content box, which means that border and padding are added to that width.</p><p>To avoid the following issues, you can set box-sizing to border-box.</p><ul><li>A block element takes up the full width of its parent. If it has a border or padding, this will add to its width, which will result in <strong>horizontal scrolling</strong>.</li><li>An element’s size can be bigger than you want it to be.</li></ul><p>In the following manner, <strong>border-box</strong> can be used for all elements:</p><pre>/* use this before normalisation */<br>*,<br>*::after,<br>*::before {<br>  box-sizing: border-box;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*_mhYZ2RvW_9igVg44s009Q.png" /></figure><p><strong>Topic : Spacing issues of Inline Elements</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*cheQAMiThBShy35siKb9Yg.png" /></figure><pre>/* html */<br>&lt;ul&gt;<br>  &lt;li class=&quot;tag&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;link&quot;&gt;Profile&lt;/a&gt;&lt;/li&gt;<br>  &lt;li class=&quot;tag&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;link&quot;&gt;About&lt;/a&gt;&lt;/li&gt;<br>  &lt;li class=&quot;tag&quot;&gt;&lt;a href=&quot;#&quot; class=&quot;link&quot;&gt;Setting&lt;/a&gt;&lt;/li&gt;<br>&lt;/ul&gt;</pre><pre>/* css */<br>.tag {<br>  display: inline-block;<br>  margin-right: 8px;<br>  background: #FCE2DB;<br>  padding: 16px;<br>}</pre><p>You would expect the distance between ul tags to equal 8 pixels, correct? This is not the case. The spacing would be 8 pixels plus an additional 1 pixel from the character spacing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*CXzHGUedqnlKdab6r1cTqQ.png" /></figure><p>To fix that you can use flex,</p><pre>ul {<br> display: flex;<br> flex-wrap: wrap;</pre><pre> /* <br>   if you need to override <br>   the browser default padding and margin of this ul element<br>   then use following <br> */<br> padding-inline-start: 0;<br> margin-block-start: 0;<br> margin-block-end: 0;<br>}</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FSachin901%2Fembed%2Fpreview%2FrNKMyPV%3Fdefault-tabs%3Dcss%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DrNKMyPV&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2FSachin901%2Fpen%2FrNKMyPV&amp;image=https%3A%2F%2Fshots.codepen.io%2FSachin901%2Fpen%2FrNKMyPV-512.jpg%3Fversion%3D1667725366&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/c16002e8dcb531765496541c8534e475/href">https://medium.com/media/c16002e8dcb531765496541c8534e475/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*D-OS2RFeoCs-Mvv-kwD0Ww.png" /></figure><p><strong>Topic : Issues with Replaced elements</strong></p><p><strong>Replaced element </strong>is an HTML element with predefined width and height, without CSS.</p><p>Here are some interesting facts about <strong>Replaced elements</strong>:</p><ul><li><strong>iframe</strong>, <strong>video</strong>, <strong>embed</strong>, <strong>img</strong>, <strong>input</strong> are considered as Replaced elements.</li><li><strong>option</strong>, <strong>audio</strong>, <strong>canvas</strong>, <strong>object</strong>, <strong>applet</strong>, <strong>br</strong>, <strong>hr</strong> are treated as replaced elements only in specific cases.</li><li>Replaced elements will not occupy their parent’s full width unless the width attribute is explicitly set.</li></ul><pre>input[type=”email”] {<br> display: block; /* The element does not take up the full width. */<br>}</pre><pre>input[type=”email”] {<br> display: block;<br> width: 100%; /* Need to give a width explicitly */<br>}</pre><pre>img { <br>  display: block; /* The element does not take up the full width. */<br>}</pre><pre>img { <br>  display: block;<br>  width: auto; /* Need to give a width explicitly */<br>  max-width: 100%;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*PJSrNklzyhWWnNOdKb6KEw.png" /></figure><ul><li>It’s not possible to use pseudo-elements with replaced elements. For<br>example, adding an ::after pseudo-element to an input is not possible.</li><li>The default size of a replaced element is 300 by 150 pixels. If your page has an img or an iframe and it doesn’t load for some reason, the browser will give it this default size.</li><li>when an image fails to load, it’s not considered a replaced element. You can actually add ::before and ::after pseudo-elements to it:</li></ul><pre>img::after {<br> content: attr(alt);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*DlsOEGUTUThar5eXe5b_mQ.png" /></figure><p><strong>Topic : Spacing Below an Image</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*MZg3Q6PGDr0H63O0AsSZLw.png" /></figure><p>img is treated as an inline element, so there is a small space beneath every image. To resolve this issue, you can convert img to a block element.</p><pre>img {<br>  display: block;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*hkvYlQFXy_UxW_21PxuMcQ.png" /></figure><p><strong>Topic : Display With Positioned Elements</strong></p><p>By default, an element with an <strong>absolute</strong> position value becomes a <strong>block-level </strong>element. Therefore, adding <strong>inline-block</strong> or <strong>block</strong> as the display type will have no effect.</p><pre>.element {<br> position: absolute;<br> left: 0;<br> top: 0;<br> width: 100px;<br> display: block; /* By default it is block */<br>}</pre><p>However, you can use the display property as follows:</p><pre>.element {<br> position: absolute;<br> right: 0;<br> top: 0;<br> display: none;<br>}</pre><pre>@media (min-width: 400px) { <br>  .element {<br>    display: block;<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*hyMN5MnMoIVEMJnVJuU0ng.png" /></figure><p><strong>Topic : Tap Highlighting issue in mobile web</strong></p><p>To remove the tap colour, you may utilise the following non-standard CSS method. However, there may be significant incompatibilities between implementations, and the behaviour may alter in the future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*XR81ygG-4IPSzAp1JEr-Rg.png" /></figure><pre>.element {<br>-webkit-tap-highlight-color: rgba(0, 0, 0, 0);<br>-webkit-tap-highlight-color: transparent;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*rSGE2JWGH4iSF1qV0gdH-A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*7_rYZhLBnDEshqQdVvF0rA.png" /></figure><p><strong>Topic : Issue with legend elements</strong></p><p>the legend element is <strong>block-level</strong> element, but it has <strong>min-width: max-content</strong> by default, which means it has the width of its text content. To make it full width, do this:</p><pre>&lt;fieldset&gt;<br>  &lt;legend&gt;Personalia:&lt;/legend&gt;<br>  &lt;label for=&quot;fname&quot;&gt;First name:&lt;/label&gt;<br>  &lt;input type=&quot;text&quot; id=&quot;fname&quot; name=&quot;fname&quot;&gt;&lt;br&gt;&lt;br&gt;<br>  &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;<br>&lt;/fieldset&gt;</pre><pre>legend {<br> width: 100%;<br>}</pre><p>Note: legend element doesn’t accept inline or inline-block it will always be block type element</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*XkJ3GGqKFcF23SLroKCaxg.png" /></figure><p><strong>Topic : Alignment issues of Inline Elements</strong></p><p>When attempting to align an icon and text, a common CSS problem occurs. You immediately observe that they are not vertically aligned. Either the icon or the text are a few pixels off. You can fix that in following way</p><pre>.icon {<br> vertical-align: middle;<br>}</pre><p>Note : <strong>vertical-align</strong> only applies to <strong>inline</strong>, <strong>inline-block</strong>, <strong>inline-flex</strong>, <strong>inline- grid</strong>, <strong>inline-table</strong> and <strong>table-cell</strong> elements; block-level elements cannot be vertically aligned using this property.</p><p>Because of the following factors, vertical alignment and estimating the vertical height of a text can be difficult.</p><ul><li>There are two heights for inline elements: the <strong>content-area</strong> (based on font metrics) and the <strong>virtual-area</strong> (line-height).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XEu8SAjlEYlmv91eiwIMnQ.png" /></figure><ul><li>Even if a specific font size is specified, it is not taken correctly.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3-970RJ-Wc9xn6CxqjGV9w.png" /></figure><p>To resolve the issue with font size, you can use <a href="https://seek-oss.github.io/capsize/"><strong>Capsize</strong></a>. With <a href="https://seek-oss.github.io/capsize/"><strong>Capsize</strong></a>, you can specify the exact height of a specific font. Check out the following example</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FSachin901%2Fembed%2Fpreview%2FwvXzVOx%3Fdefault-tabs%3Dcss%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DwvXzVOx&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2FSachin901%2Fpen%2FwvXzVOx&amp;image=https%3A%2F%2Fshots.codepen.io%2FSachin901%2Fpen%2FwvXzVOx-512.jpg%3Fversion%3D1667841463&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/37dd840539ab9b9e2f1c598fbca04e29/href">https://medium.com/media/37dd840539ab9b9e2f1c598fbca04e29/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*zb0OhFBjhIhFkN-vpCXVyQ.png" /></figure><p><strong>Topic : Margin collapse issues</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j04V8ZwAMOEClaykaDpJrg.png" /></figure><p>To avoid the above issue, use directional margins. For example, adding a margin-bottom to every element. Note that if an element belongs to a flexbox or grid container, its margins will not collapse.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*LWRg3o7jjfxQc1o55_weZw.png" /></figure><p><strong>Topic : Margin auto not working with inline elements</strong></p><p>By using auto margin, you can align a block element horizontally, but not an inline element. Therefore, to align horizontally, you must convert to a block element.</p><pre>span {<br> width: 100px;<br> margin: 0 auto; /* this won&#39;t work */<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*q4tEYdxOQzq970J-dEEa0w.png" /></figure><p><strong>Topic : Auto margin with flexbox</strong></p><p>You can use margin:auto to completely shift an element in one direction. Check out how the <strong>margin-left: auto;</strong> works in the example below:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FSachin901%2Fembed%2Fpreview%2FRwJoEmV%3Fdefault-tabs%3Dcss%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DRwJoEmV&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2FSachin901%2Fpen%2FRwJoEmV&amp;image=https%3A%2F%2Fshots.codepen.io%2FSachin901%2Fpen%2FRwJoEmV-512.jpg%3Fversion%3D1667930763&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/a731dfb6fae961958ec3b947573eb358/href">https://medium.com/media/a731dfb6fae961958ec3b947573eb358/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*_lgMdOdAA7WJ_cb8EUaZ4w.png" /></figure><p>Issue: Percentage Based Height is not working as expected</p><p>Reason: You cannot set the height of an element as a percentage unless the height of its parent is explicitly defined.</p><p>Solution: Give a height to the parent element.</p><p>Refer to following example</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FSachin901%2Fembed%2Fpreview%2FPoaJMvV%3Fdefault-tabs%3Dcss%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DPoaJMvV&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2FSachin901%2Fpen%2FPoaJMvV&amp;image=https%3A%2F%2Fshots.codepen.io%2FSachin901%2Fpen%2FPoaJMvV-512.jpg%3Fversion%3D1668707215&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3a7e0342e0e2eac94f73082f09d188c/href">https://medium.com/media/c3a7e0342e0e2eac94f73082f09d188c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*6X9vH8-r14HmuIXcfzVRsw.png" /></figure><p>Issue: Uneven card height layouts</p><p>Solution: By default, CSS grid will equalise the card heights. However, you must use flex to expand the inner content proportionally.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FSachin901%2Fembed%2Fpreview%2FdyKZbpq%3Fdefault-tabs%3Dhtml%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DdyKZbpq&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2FSachin901%2Fpen%2FdyKZbpq&amp;image=https%3A%2F%2Fshots.codepen.io%2FSachin901%2Fpen%2FdyKZbpq-512.jpg%3Fversion%3D1668709498&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/f87f46f697e55a16a13ced379763b473/href">https://medium.com/media/f87f46f697e55a16a13ced379763b473/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2a7cb1538da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conditional Border Radius using CSS]]></title>
            <link>https://medium.com/@duminda.g.k/conditional-border-radius-using-css-d59e0c83d14d?source=rss-de7d3f4c57df------2</link>
            <guid isPermaLink="false">https://medium.com/p/d59e0c83d14d</guid>
            <dc:creator><![CDATA[Duminda Gayan Kodagoda]]></dc:creator>
            <pubDate>Sat, 29 Oct 2022 15:04:09 GMT</pubDate>
            <atom:updated>2022-10-30T04:51:30.828Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you want to switch a value between<strong> two numbers</strong> when a container changes from <strong>100vw</strong> to a smaller size without JavaScript? you can use the <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/calc"><strong>calc()</strong></a> function for that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cqj5egMvOqtHaMzWEKuDrA.jpeg" /></figure><p>In the above example, the <strong>border-radius</strong> changes from <strong>8px</strong> to <strong>0px</strong> when it reaches the <strong>mobile view</strong>. for that, you can use <strong>media queries</strong> in the following way. But If you are using flex-wrap: wrap; then <strong>media query</strong> is not the best way. You can use <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Container_Queries"><strong>container queries</strong></a> in such cases but need to consider browser support.<br><a href="https://caniuse.com/?search=Container%20Queries">https://caniuse.com/?search=Container%20Queries</a></p><pre><strong>.card {<br>  </strong>border-radius: 0px;<br><strong>}</strong></pre><pre><strong>@media</strong> (min-width: 700px) {<br>    <strong>.card</strong> {<br>        border-radius: 8px;    <br>    }<br>}</pre><p>Following is a nicer way to handle the above issue.</p><pre><strong>.card</strong> {<br>   border-radius: max(0px, min(8px, calc((100vw - 100%) * 9999)));<br>}</pre><ol><li>calc((100vw - 100%) * 9999)): Here, If the container width is close to 100vw then this will be evaluated into 0 and if the container width is less than 100vw then it will be evaluated into a larger positive value.</li><li>min(8px, calc((100vw - 100%) * 9999)): Here, the <strong>min value</strong> between 8px and the <strong>result of calc(…) </strong>will be considered.</li><li>max(0px, min(8px, calc((100vw - 100%) * 9999))): Here, <strong>max value</strong> between 0px and the <strong>result of min(…) </strong>will be considered.</li></ol><p>If the container doesn’t reach the <strong>100vw</strong> then you can do a small modification and use it.</p><pre>max(0px, min(8px, calc((100vw - 4px - 100%) * 9999)))</pre><p>You can use <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/clamp"><strong>clamp()</strong></a> in the following way but need to consider browser support. <a href="https://caniuse.com/?search=clamp">https://caniuse.com/?search=clamp</a></p><pre>border-radius: clamp(0px, ((100vw - 4px) - 100%) * 9999, 8px);</pre><p><strong>Code example</strong></p><p>Check the <strong>left_card</strong> and <strong>right_inner </strong>classes where the <strong>border-radius</strong> and <strong>margin </strong>are conditionally updated without <strong>media queries</strong>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FSachin901%2Fembed%2Fpreview%2FZERGZrJ%3Fdefault-tabs%3Dhtml%252Cresult%26height%3D600%26host%3Dhttps%253A%252F%252Fcodepen.io%26slug-hash%3DZERGZrJ&amp;display_name=CodePen&amp;url=https%3A%2F%2Fcodepen.io%2FSachin901%2Fpen%2FZERGZrJ&amp;image=https%3A%2F%2Fshots.codepen.io%2FSachin901%2Fpen%2FZERGZrJ-512.jpg%3Fversion%3D1667054851&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/35660b7527bc1a43860d157ce020bc41/href">https://medium.com/media/35660b7527bc1a43860d157ce020bc41/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d59e0c83d14d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>