Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • Asp.Net Core
  • C#
  • SQL
  • JavaScript
  • CSS
  • About
  • ErcanOPAK.com
  • No Access
  • Privacy Policy

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

Tag: Responsive Design

CSS

CSS: Fix Container Queries Never Triggering Because the Parent Element Was Never Given an Explicit container-type

- 01.11.26 - ErcanOPAK comment on CSS: Fix Container Queries Never Triggering Because the Parent Element Was Never Given an Explicit container-type

🎨 Fix Container Queries Never Triggering Because the Parent Element Was Never Given an Explicit container-type A container query lets a component adapt its own layout based on the size of its nearest ancestor rather than the viewport, which is exactly what makes it useful for a component that gets reused in a wide sidebar […]

Read More
CSS

CSS: Fix a Container Query Unit Computing Against the Wrong Ancestor Because Only the Nearest container-type Element Counts

- 30.10.26 - ErcanOPAK comment on CSS: Fix a Container Query Unit Computing Against the Wrong Ancestor Because Only the Nearest container-type Element Counts

🎨 Fix a Container Query Unit Computing Against the Wrong Ancestor Because Only the Nearest container-type Element Counts A container query length unit like cqw always resolves against the nearest ancestor that has container-type set on the relevant axis – it does not know or care which container you intended as ‘the’ container when you […]

Read More
CSS

CSS: Fix a scroll-snap-align Carousel Snapping to the Wrong Slide Every Time You Resize the Browser Window

- 29.10.26 - ErcanOPAK comment on CSS: Fix a scroll-snap-align Carousel Snapping to the Wrong Slide Every Time You Resize the Browser Window

🎨 Fix a scroll-snap-align Carousel Snapping to the Wrong Slide Every Time You Resize the Browser Window Scroll snapping calculates its snap points from each item’s actual box geometry, which the browser recomputes immediately on any resize – but the scroll container’s current scroll offset doesn’t get recalculated at the same time. If slides are […]

Read More
CSS

CSS: Fix Text Inside a Flex Item Overflowing Past a Fixed-Width Sibling Because Flex Items Default to a Minimum Width of Their Content

- 29.10.26 - ErcanOPAK comment on CSS: Fix Text Inside a Flex Item Overflowing Past a Fixed-Width Sibling Because Flex Items Default to a Minimum Width of Their Content

🎨 Fix Text Inside a Flex Item Overflowing Past a Fixed-Width Sibling Because Flex Items Default to a Minimum Width of Their Content Every flex item’s computed min-width defaults to auto, which resolves to the size of its content’s longest unbreakable run – not zero – so a flex-basis or flex-grow value is only ever […]

Read More
CSS

CSS: Fix a Hover State That Gets Stuck On After a Tap on Touchscreens Because Touch Events Simulate Hover Without Ever Firing Its Exit

- 28.10.26 - ErcanOPAK comment on CSS: Fix a Hover State That Gets Stuck On After a Tap on Touchscreens Because Touch Events Simulate Hover Without Ever Firing Its Exit

🎨 Fix a Hover State That Gets Stuck On After a Tap on Touchscreens Because Touch Events Simulate Hover Without Ever Firing Its Exit A mouse enters an element to trigger hover and leaves it to end it, which is a pair of events a touchscreen simply has no equivalent for. To keep hover-only designs […]

Read More
CSS

CSS: Fix a Table Column’s Width Ignoring Every CSS Rule Because the Browser’s Own Table Layout Algorithm Took Over

- 23.10.26 - ErcanOPAK comment on CSS: Fix a Table Column’s Width Ignoring Every CSS Rule Because the Browser’s Own Table Layout Algorithm Took Over

🎨 Fix a Table Column’s Width Ignoring Every CSS Rule Because the Browser’s Own Table Layout Algorithm Took Over Setting a width on a table cell or column and watching the browser render a completely different width anyway isn’t a sign the CSS rule has the wrong selector – by default, tables use the automatic […]

Read More
CSS

CSS: Fix an aspect-ratio Box That Gets Silently Ignored Because an Explicit height Was Also Set on the Element

- 11.10.26 - ErcanOPAK comment on CSS: Fix an aspect-ratio Box That Gets Silently Ignored Because an Explicit height Was Also Set on the Element

🎨 The aspect-ratio That Lost to a Height Set Years Ago The aspect-ratio property is built to compute whichever dimension you leave unspecified from the one you do provide, which means it only ever gets a chance to do anything on an axis that isn’t already pinned down by an explicit width or height. A […]

Read More
CSS

CSS: Fix an aspect-ratio Box That Collapses to Zero Height Because Its Parent Has No Defined Width

- 04.10.26 - ErcanOPAK comment on CSS: Fix an aspect-ratio Box That Collapses to Zero Height Because Its Parent Has No Defined Width

🎨 The Aspect Ratio Box That Had Nothing to Be a Ratio Of The aspect-ratio property computes a box’s height as a ratio of its width, but it needs an actual resolved width to do that math against in the first place. A box sitting inside a parent that itself has no defined width – […]

Read More
CSS

CSS: Fix a Container Query That Never Triggers Because of a Missing Containment Property

- 27.09.26 - ErcanOPAK comment on CSS: Fix a Container Query That Never Triggers Because of a Missing Containment Property

🎨 The Container Query That Was Watching an Element That Wasn’t a Container An @container rule only ever evaluates against the nearest ancestor that has actually been established as a query container via the container-type property – simply nesting an element inside any ancestor and writing an @container rule does nothing at all if that […]

Read More
CSS

CSS: Fix an Image That Distorts Instead of Cropping Inside a Fixed-Size Container

- 06.09.26 - ErcanOPAK comment on CSS: Fix an Image That Distorts Instead of Cropping Inside a Fixed-Size Container

🎨 Your Images Squish and Stretch Instead of Cropping to Fit Their Container Images of varying aspect ratios are placed into a fixed-size container – a grid of thumbnails, a card layout – and instead of cropping to fill the space cleanly, every image squishes or stretches to match the container’s exact dimensions, because `width`/`height` […]

Read More
HTML

HTML5: Fix a Page That Zooms In Automatically on Mobile When You Tap an Input

- 31.08.26 - ErcanOPAK comment on HTML5: Fix a Page That Zooms In Automatically on Mobile When You Tap an Input

🧩 iOS Zooms In the Instant Someone Taps Your Input A form looks perfectly normal on desktop, but on an iPhone, the second a user taps into any text field, Safari zooms the entire page in – and it stays zoomed even after they finish typing, leaving them to manually pinch back out just to […]

Read More
CSS

CSS: Fix Text That Overflows Its Container Instead of Wrapping With One Property

- 31.08.26 | 31.08.26 - ErcanOPAK comment on CSS: Fix Text That Overflows Its Container Instead of Wrapping With One Property

🎨 Long Word Breaking Your Layout? One Property Fixes It A single unbroken long word or URL — not spaces-separated text, which wraps fine by default — can push right through a container’s edge and break your entire layout, and the fix is one CSS property most people never learn exists. 🐞 The Problem <div […]

Read More
CSS

CSS: Fix Flexbox Items That Refuse to Shrink Below Their Content Size

- 30.08.26 | 31.08.26 - ErcanOPAK comment on CSS: Fix Flexbox Items That Refuse to Shrink Below Their Content Size

🎨 min-width: auto Is Secretly Winning A flex item with flex-shrink: 1 that still overflows its container — text spilling out, images pushing past the edge — almost always has one invisible default working against it: flex items refuse to shrink below their content’s natural size unless you explicitly tell them otherwise. 🐞 The Problem […]

Read More
CSS

CSS: Fix the Horizontal Scrollbar Nightmare With Two Properties Nobody Sets by Default

- 30.08.26 - ErcanOPAK comment on CSS: Fix the Horizontal Scrollbar Nightmare With Two Properties Nobody Sets by Default

🎨 border-box = No More Scrollbars A single wide image, a long word, or one element with a fixed width breaks your entire page layout sideways — and hunting down which element is causing it can eat an entire afternoon. 🐞 The Problem /* This innocent-looking rule can cause horizontal overflow: */ .card { width: […]

Read More
CSS

CSS: Container Queries ile Component-Based Responsive Design

- 18.08.26 - ErcanOPAK comment on CSS: Container Queries ile Component-Based Responsive Design

πŸ“¦ Container Queries = Component Responsive Media queries yeterli değil. CSS Container Queries ile component bazlΔ± responsive design yapΔ±n. 🎯 Container Queries Γ–rnekleri /* 1. Container Definition */ .card-container { container-type: inline-size; container-name: card; } /* 2. Container Query */ @container card (min-width: 300px) { .card { display: flex; flex-direction: row; gap: 16px; } .card-image […]

Read More
CSS

CSS: Responsive Design with CSS Grid and Flexbox

- 17.08.26 - ErcanOPAK comment on CSS: Responsive Design with CSS Grid and Flexbox

πŸ“± Responsive Design = Mobile-First Every device needs a great experience. CSS Grid and Flexbox enable responsive, mobile-first layouts for all screen sizes. πŸ“ Responsive Patterns // Mobile-First Grid .grid-container { display: grid; grid-template-columns: 1fr; gap: 16px; } // Tablet @media (min-width: 768px) { .grid-container { grid-template-columns: repeat(2, 1fr); } } // Desktop @media (min-width: […]

Read More
CSS

CSS: Use Aspect Ratio for Perfectly Sized Boxes

- 30.05.26 - ErcanOPAK comment on CSS: Use Aspect Ratio for Perfectly Sized Boxes

πŸ“ No More Padding Hack Remember padding-bottom: 56.25% for 16:9? aspect-ratio property does it natively. Videos, images, cards β€” perfect proportions. πŸ“ Basic Usage /* Square */ .square { aspect-ratio: 1 / 1; background: blue; width: 200px; } /* 16:9 video container */ .video-container { aspect-ratio: 16 / 9; background: black; width: 100%; } /* […]

Read More
CSS

CSS: Use Container Queries for Component-Level Responsive Design

- 26.05.26 - ErcanOPAK comment on CSS: Use Container Queries for Component-Level Responsive Design

πŸ“¦ Components That Adapt to Their Parent Media queries look at viewport. Container queries look at parent container size. Finally, truly reusable responsive components. ❌ Old Way (Media Queries) .card { display: flex; flex-direction: column; } @media (min-width: 800px) { .card { flex-direction: row; /* Changes everywhere */ } } βœ… Container Queries .sidebar { […]

Read More
CSS

CSS: Use Grid auto-fit and auto-fill for Responsive Layouts Without Media Queries

- 26.05.26 - ErcanOPAK comment on CSS: Use Grid auto-fit and auto-fill for Responsive Layouts Without Media Queries

πŸ“± Responsive Grids, Zero Media Queries Media queries for every breakpoint? Tedious. Grid auto-fit/auto-fill creates responsive layouts automatically. Items reflow based on space available. The Magic Formula .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; } /* That’s it! Fully responsive without media queries Items wrap automatically based on available space */ auto-fit […]

Read More
CSS

CSS: Use Grid auto-fit and auto-fill for Responsive Layouts Without Media Queries

- 30.03.26 - ErcanOPAK comment on CSS: Use Grid auto-fit and auto-fill for Responsive Layouts Without Media Queries

πŸ“± Responsive Grids, Zero Media Queries Media queries for every breakpoint? Tedious. Grid auto-fit/auto-fill creates responsive layouts automatically. Items reflow based on space available. The Magic Formula .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; } /* That’s it! Fully responsive without media queries Items wrap automatically based on available space */ 🎯 […]

Read More
CSS

CSS: Use Container Queries for True Component-Based Responsive Design

- 22.03.26 - ErcanOPAK comment on CSS: Use Container Queries for True Component-Based Responsive Design

πŸ“¦ Responsive Components, Not Just Pages Media queries check viewport width. Component in sidebar? Full width? Same breakpoint fails. Container queries check parent width. The Problem with Media Queries ❌ Media Queries /* Card component */ .card { display: flex; } @media (max-width: 768px) { .card { flex-direction: column; /* Stack on mobile */ } […]

Read More
CSS

CSS: Container Queries – The End of Media Queries?

- 01.03.26 - ErcanOPAK comment on CSS: Container Queries – The End of Media Queries?

Media queries react to the viewport. Container queries react to the parent element’s size. This is a revolution for component-based design. .card-container { container-type: inline-size; } @container (min-width: 400px) { .card { display: flex; flex-direction: row; } } Why? Now your card component can be placed in a sidebar or a main feed and it […]

Read More
CSS

CSS: Mastering ‘Subgrid’ for Perfect Multi-Card Alignment

- 01.03.26 - ErcanOPAK comment on CSS: Mastering ‘Subgrid’ for Perfect Multi-Card Alignment

Ever had a row of cards where the headers didn’t align because of text length? Subgrid solves the biggest headache in CSS Grid. .container { display: grid; grid-template-rows: repeat(3, auto); } .card { display: grid; grid-template-rows: subgrid; grid-row: span 3; } This tells the card to inherit the row sizing of its parent, ensuring all […]

Read More
CSS

CSS: Solving the ‘Jumping Content’ Problem with aspect-ratio

- 28.02.26 - ErcanOPAK comment on CSS: Solving the ‘Jumping Content’ Problem with aspect-ratio

Before an image loads, the browser doesn’t know its height, causing the layout to ‘jump’ (Cumulative Layout Shift – CLS). This is bad for SEO. .video-container { width: 100%; aspect-ratio: 16 / 9; background: #eee; /* Placeholder */ } The Result: The browser reserves the space before the content arrives, resulting in a smooth, professional […]

Read More
CSS

CSS Grid + Subgrid: The Layout Technique That Killed My Need for Flexbox

- 23.02.26 - ErcanOPAK comment on CSS Grid + Subgrid: The Layout Technique That Killed My Need for Flexbox

🎨 The Layout Revolution Flexbox was great. But CSS Grid + Subgrid? It’s game over. Layouts that took 200 lines of CSS now take 10. The Problem Subgrid Solves ❌ The Old Nightmare You have a card grid. Each card has a title, image, description, and button. You want all titles aligned, all images the […]

Read More
CSS

CSS: Creating App-like Scrolling Experiences with ‘Scroll Snap’

- 21.02.26 - ErcanOPAK comment on CSS: Creating App-like Scrolling Experiences with ‘Scroll Snap’

Stop using heavy JS sliders. Use pure CSS to make your image galleries feel like a mobile app. .container { scroll-snap-type: x mandatory; overflow-x: scroll; display: flex; } .item { scroll-snap-align: center; flex: 0 0 100%; } Result: Smooth, flick-to-scroll galleries that work perfectly on touch screens.

Read More
HTML

HTML5: Professional Image Optimization with and WebP

- 21.02.26 - ErcanOPAK comment on HTML5: Professional Image Optimization with and WebP

Don’t serve giant JPEGs to mobile users. Use modern formats with fallbacks. This approach saves up to 70% in bandwidth while ensuring every browser sees the image.

Read More
CSS

CSS: Solving the Nested Grid Problem with ‘subgrid’

- 21.02.26 - ErcanOPAK comment on CSS: Solving the Nested Grid Problem with ‘subgrid’

Aligning elements inside nested components was nearly impossible until CSS Subgrid arrived. .parent { display: grid; grid-template-columns: 1fr 2fr 1fr; } .child { grid-column: 1 / 4; display: grid; grid-template-columns: subgrid; } Now, the child’s items will align perfectly with the parent’s columns. Professional, pixel-perfect layout achieved.

Read More
CSS

CSS: Use Grid auto-fit and minmax for Responsive Layouts Without Media Queries

- 15.02.26 - ErcanOPAK comment on CSS: Use Grid auto-fit and minmax for Responsive Layouts Without Media Queries

Media queries for every screen size is tedious. CSS Grid auto-fit + minmax creates responsive layouts automatically. Traditional Responsive: .grid { display: grid; grid-template-columns: repeat(4, 1fr); } @media (max-width: 1200px) { .grid { grid-template-columns: repeat(3, 1fr); } } @media (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); } } @media (max-width: 600px) { .grid { […]

Read More
CSS

CSS: Use clamp() for Responsive Font Sizes Without Media Queries

- 14.02.26 - ErcanOPAK comment on CSS: Use clamp() for Responsive Font Sizes Without Media Queries

Setting font sizes for mobile, tablet, desktop with media queries is tedious. clamp() does it automatically. Old Way – Multiple Media Queries: h1 { font-size: 24px; } @media (min-width: 768px) { h1 { font-size: 32px; } } @media (min-width: 1200px) { h1 { font-size: 48px; } } New Way – One Line: h1 { font-size: […]

Read More
Page 1 of 2
1 2 Next Β»

Posts pagination

1 2 Next »
November 2026
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
« Oct    

Most Viewed Posts

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

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit
  • SQL Server: Fix ROW_NUMBER Ties Reordering Between Identical Runs
  • C#: Fix an Enum HasFlag Returning True for the Zero Value
  • WordPress: Fix Featured Images Vanishing After a CDN Migration
  • Photoshop: Fix Content-Aware Fill Smearing a Repeating Pattern
  • Asp.Net Core: Fix Antiforgery Tokens Rejected Behind a Reverse Proxy

Most Viewed Posts

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

Recent Posts

  • C#: Fix a ConditionalWeakTable Entry Vanishing Too Soon
  • Docker: Fix a Stale COPY Layer After Editing .dockerignore
  • Photoshop: Fix a Pattern Overlay Scaling Wrong on a High-DPI File
  • SQL Server: Fix a Computed Column Index Skipped by Implicit Cast
  • HTML5: Fix a required Input Inside a Hidden Tab Blocking Submit

Social

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