Skip to content

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

Category: CSS

CSS

Why position: sticky Randomly Stops Working

- 29.01.26 - ErcanOPAK comment on Why position: sticky Randomly Stops Working

Sticky works… until it doesn’t. Actual rules Parent must NOT have overflow: hidden|auto|scroll Sticky only works within scroll container Z-index context matters Fix Move sticky element outside overflow containers.

Read More
CSS

:where() for Zero-Specificity Styling

- 28.01.26 - ErcanOPAK comment on :where() for Zero-Specificity Styling

:where(button) { margin: 0; } Why it mattersStyle globally without specificity wars.

Read More
CSS

aspect-ratio Ends Padding Hacks Forever

- 27.01.26 - ErcanOPAK comment on aspect-ratio Ends Padding Hacks Forever

.video { aspect-ratio: 16 / 9; } Why it mattersCleaner layouts, zero JS.

Read More
CSS

Use clamp() for Perfect Responsive Font Sizes

- 26.01.26 - ErcanOPAK comment on Use clamp() for Perfect Responsive Font Sizes

font-size: clamp(1rem, 2vw, 1.5rem); Why it mattersOne rule replaces media queries.

Read More
CSS

Stop Fighting Layouts — Use gap Instead of Margins

- 25.01.26 - ErcanOPAK comment on Stop Fighting Layouts — Use gap Instead of Margins

Margins break when layouts change direction. .container { display: flex; gap: 16px; } Why this mattersCleaner CSS, fewer overrides, better responsive behavior.

Read More
CSS

The Real Fix for Sticky Headers That Jump on Scroll

- 24.01.26 - ErcanOPAK comment on The Real Fix for Sticky Headers That Jump on Scroll

The issue is usually layout reflow, not position: sticky. header { position: sticky; top: 0; will-change: transform; } Why this workswill-change hints the browser to optimize rendering early.

Read More
CSS

CSS Animations Cause Scroll Jank

- 23.01.26 - ErcanOPAK comment on CSS Animations Cause Scroll Jank

UI feels heavy. Why it happensAnimating layout properties. Why it mattersBad UX on mobile. Vital fix Use transform & opacity only  

Read More
CSS

CSS Layout Breaks on Mobile Only

- 22.01.26 - ErcanOPAK comment on CSS Layout Breaks on Mobile Only

Desktop perfect, mobile chaos. Why it happensFixed widths ignore viewport. Why it mattersMobile users bounce. Smart fixUse min() and max(). .container { width: min(100%, 1200px); }  

Read More
CSS

CSS Animations Cause Page Jank

- 21.01.26 - ErcanOPAK comment on CSS Animations Cause Page Jank

Smooth animation on desktop, stutter on mobile. Why it happensAnimating layout properties. Why it mattersPoor perceived performance. Smart fixAnimate transform and opacity only. .element { transform: translateX(20px); }  

Read More
CSS

CSS Layouts Break on Small Screens

- 18.01.26 - ErcanOPAK comment on CSS Layouts Break on Small Screens

Desktop perfect, mobile chaos. WhyFixed widths instead of flexible units. TipUse max-width and % instead of px. .container { max-width: 1200px; width: 100%; }  

Read More
CSS

CSS Animations Cause Jank on Mobile

- 16.01.26 - ErcanOPAK comment on CSS Animations Cause Jank on Mobile

Smooth on desktop, choppy on phone. WhyLayout-triggering properties used. TipAnimate only transform and opacity. .element { transform: translateZ(0); }  

Read More
CSS

CSS Flex Layouts Break with Dynamic Content

- 15.01.26 - ErcanOPAK comment on CSS Flex Layouts Break with Dynamic Content

Static demos work, real data fails. WhyFlex items grow beyond assumptions. TipUse min-width: 0 on flex children. .flex-item { min-width: 0; }  

Read More
CSS

CSS Layouts Break When Fonts Load Late

- 14.01.26 - ErcanOPAK comment on CSS Layouts Break When Fonts Load Late

Flash of broken layout. WhyFont loading changes element dimensions. TipUse font-display and fallback sizing.

Read More
CSS

CSS Hover Effects Cause Unexpected Layout Shifts

- 13.01.26 - ErcanOPAK comment on CSS Hover Effects Cause Unexpected Layout Shifts

UI jumps on hover. WhyBorders and size changes affect layout flow. Tip Reserve space using transparent borders.

Read More
CSS

CSS Sticky Elements Break Layouts

- 12.01.26 - ErcanOPAK comment on CSS Sticky Elements Break Layouts

Works in demos, fails in real pages. WhyOverflow settings disable sticky behavior. Tip Avoid overflow hidden on parent containers.

Read More
CSS

CSS Animations Drain Battery on Laptops

- 11.01.26 - ErcanOPAK comment on CSS Animations Drain Battery on Laptops

Looks smooth. Battery dies. WhyAnimating layout properties triggers reflow. Fix Animate transform and opacity only.

Read More
CSS

CSS Layouts Break on Large Screens Only

- 07.01.26 | 07.01.26 - ErcanOPAK comment on CSS Layouts Break on Large Screens Only

Mobile and desktop fine, ultrawide broken. WhyFixed max-width assumptions. Fix Use fluid containers with max-width limits instead of fixed layouts.

Read More
CSS

CSS Animations Lag on Mobile Only

- 06.01.26 - ErcanOPAK comment on CSS Animations Lag on Mobile Only

Desktop smooth, mobile stutters. WhyLayout-triggering properties. Fix transform: translateZ(0);  

Read More
CSS

CSS position: fixed Jitters on Mobile

- 05.01.26 - ErcanOPAK comment on CSS position: fixed Jitters on Mobile

UI shakes while scrolling. WhyMobile browsers repaint fixed layers. Fix will-change: transform;  

Read More
CSS

CSS vh Breaks Mobile Layouts

- 04.01.26 - ErcanOPAK comment on CSS vh Breaks Mobile Layouts

Design jumps on scroll. WhyMobile browsers change viewport height dynamically. Fix height: 100dvh;  

Read More
CSS

CSS Grid Layout Breaks on Small Screens

- 03.01.26 - ErcanOPAK comment on CSS Grid Layout Breaks on Small Screens

Looks fine on desktop, broken on mobile. WhyImplicit grid tracks expand unexpectedly. Fix grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));  

Read More
CSS

CSS Animations Cause Jank on Mobile

- 03.01.26 - ErcanOPAK comment on CSS Animations Cause Jank on Mobile

Smooth on desktop, laggy on phones. WhyLayout-triggering properties. Fix .element { transform: translateY(0); transition: transform 300ms ease; }  

Read More
CSS

CSS Animations Cause Page Jank

- 02.01.26 - ErcanOPAK comment on CSS Animations Cause Page Jank

Smooth on desktop, laggy on mobile. WhyLayout-triggering properties. Fix Animate only transform and opacity. .box { transform: translateX(0); transition: transform 300ms ease; }  

Read More
CSS

CSS position: sticky Not Working?

- 01.01.26 - ErcanOPAK comment on CSS position: sticky Not Working?

It’s not broken — it’s constrained. Why it happensParent container has overflow: hidden. FixRemove overflow or move sticky element.

Read More
CSS

CSS — aspect-ratio Fixes Responsive Media Instantly

- 31.12.25 - ErcanOPAK comment on CSS — aspect-ratio Fixes Responsive Media Instantly

Stop using padding hacks. video { aspect-ratio: 16 / 9; }  

Read More
CSS / Development

CSS — min-width: 0 Fixes Broken Flex Layouts

- 30.12.25 | 30.12.25 - ErcanOPAK comment on CSS — min-width: 0 Fixes Broken Flex Layouts

Flex items refuse to shrink by default. ✅ Fix min-width: 0;  

Read More
CSS

CSS — gap Works for Flexbox (Not Just Grid!)

- 29.12.25 - ErcanOPAK comment on CSS — gap Works for Flexbox (Not Just Grid!)

Many devs still use margins. display: flex; gap: 12px; Cleaner, safer layouts.

Read More
CSS

The aspect-ratio property

- 29.12.25 | 29.12.25 - ErcanOPAK comment on The aspect-ratio property

The Problem: Images or video embeds cause “Layout Shift” (jumping content) while loading because the browser doesn’t know their height yet. The Fix: Use aspect-ratio. No need for the old “padding-bottom percentage” hack. .card-image { width: 100%; aspect-ratio: 16 / 9; /* Automatically reserves the space */ object-fit: cover; }  

Read More
CSS

CSS — display: none Skips Layout but Breaks Animations

- 28.12.25 - ErcanOPAK comment on CSS — display: none Skips Layout but Breaks Animations

Hidden elements cannot animate. ✅ Alternative Use: visibility: hidden;  

Read More
CSS

CSS — height: 100% Does Nothing Without Context

- 27.12.25 - ErcanOPAK comment on CSS — height: 100% Does Nothing Without Context

This fails silently: .child { height: 100%; } 🧠 Reason Parent has no explicit height. ✅ Fix Define height on all parents.

Read More
Page 2 of 3
« Previous 1 2 3 Next »

Posts navigation

Older posts
Newer posts
April 2026
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
27282930  
« Mar    

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (858)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (754)
  • Add Constraint to SQL Table to ensure email contains @ (578)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (564)
  • Average of all values in a column that are not zero in SQL (531)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (489)
  • Find numbers with more than two decimal places in SQL (447)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries
  • SQL: Use Window Functions for Advanced Analytical Queries
  • .NET Core: Use Background Services for Long-Running Tasks
  • .NET Core: Use Minimal APIs for Lightweight HTTP Services
  • Git: Use Cherry-Pick to Apply Specific Commits Across Branches
  • Git: Use Interactive Rebase to Clean Up Commit History Before Merge

Most Viewed Posts

  • Get the User Name and Domain Name from an Email Address in SQL (950)
  • How to add default value for Entity Framework migrations for DateTime and Bool (858)
  • Get the First and Last Word from a String or Sentence in SQL (836)
  • How to select distinct rows in a datatable in C# (805)
  • How to make theater mode the default for Youtube (754)

Recent Posts

  • C#: Use Init-Only Setters for Immutable Objects After Construction
  • C#: Use Expression-Bodied Members for Concise Single-Line Methods
  • C#: Enable Nullable Reference Types to Eliminate Null Reference Exceptions
  • C#: Use Record Types for Immutable Data Objects
  • SQL: Use CTEs for Readable Complex Queries

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com