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

Category: CSS

CSS

CSS: Use text-overflow: ellipsis for Truncated Text

- 13.06.26 - ErcanOPAK comment on CSS: Use text-overflow: ellipsis for Truncated Text

… Long Text Looks Bad, Add Ellipsis Long titles break layouts. text-overflow: ellipsis truncates with “…”. Cleaner UI, consistent dimensions. πŸ“ Basic Ellipsis .truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 200px; } /* Multi-line truncation (WebKit) */ .multiline-truncate { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; } /* Fallback for […]

Read More
CSS

CSS: Use user-select to Prevent Text Selection

- 07.06.26 - ErcanOPAK comment on CSS: Use user-select to Prevent Text Selection

🚫 Stop Users from Selecting UI Elements Double-clicking button selects text. Dragging mouse selects UI labels. user-select prevents accidental selection. Better UX. πŸ“ Basic Usage /* Prevent selection on entire app */ body { user-select: none; } /* Allow selection on specific elements */ .content { user-select: text; } /* Buttons and UI elements */ […]

Read More
CSS

CSS: Use scroll-behavior: smooth for Smooth Page Navigation

- 07.06.26 - ErcanOPAK comment on CSS: Use scroll-behavior: smooth for Smooth Page Navigation

πŸ“œ Instant Jump is Jarring. Smooth is Better. Anchor links jump instantly. scroll-behavior: smooth animates scrolling. Better UX, no JavaScript. πŸ“ Basic Usage /* Apply to entire page */ html { scroll-behavior: smooth; } /* Apply only to specific container */ .scroll-container { scroll-behavior: smooth; overflow-y: auto; height: 400px; } /* HTML structure */ <a […]

Read More
CSS

CSS: Use :focus-visible for Better Focus Indicators

- 06.06.26 - ErcanOPAK comment on CSS: Use :focus-visible for Better Focus Indicators

⌨️ Show Focus Only for Keyboard Users Mouse users don’t need focus rings. Keyboard users do. :focus-visible shows focus only when needed. Best of both worlds. ❌ :focus (Always Shows) /* Ugly outline on mouse click */ button:focus { outline: 2px solid blue; } /* Mouse users see blue ring unnecessarily */ βœ… :focus-visible (Smart) […]

Read More
CSS

CSS: Use @property to Define Typed Custom Properties

- 06.06.26 - ErcanOPAK comment on CSS: Use @property to Define Typed Custom Properties

πŸ“ CSS Variables Now Have Types! CSS variables are strings. @property defines types: number, color, length. Enables smooth transitions. πŸ“ Defining Typed Properties @property –progress { syntax: ”; inherits: false; initial-value: 0%; } @property –primary-color { syntax: ”; inherits: true; initial-value: #3498db; } @property –spacing { syntax: ‘ | ‘; inherits: false; initial-value: 0px; } […]

Read More
CSS

CSS: Use Container Style Queries to Respond to Parent Styling

- 06.06.26 - ErcanOPAK comment on CSS: Use Container Style Queries to Respond to Parent Styling

🎨 Not Just Size, But Parent’s CSS Properties Container queries check parent size. Style queries check parent CSS values. Dark mode per component? Yes. πŸ“ Basic Style Query .card { container-name: card; container-type: inline-size; } @container card style(–theme: dark) { .card { background: #1a1a2e; color: #e0e0e0; border-color: #333; } } @container card style(–theme: light) { […]

Read More
CSS

CSS: Use Scroll-Driven Animations for Parallax Without JS

- 05.06.26 - ErcanOPAK comment on CSS: Use Scroll-Driven Animations for Parallax Without JS

πŸ“œ Animation Tied to Scroll Position Scroll-triggered animations needed JavaScript. Scroll-driven animations are pure CSS. Progress bar, reveal on scroll, parallax β€” all native. πŸ“ Basic Scroll Progress /* Progress bar that fills as you scroll */ @keyframes grow-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } } .progress-bar { position: fixed; […]

Read More
CSS

CSS: Use Variable Fonts for Multiple Weights in One File

- 05.06.26 - ErcanOPAK comment on CSS: Use Variable Fonts for Multiple Weights in One File

πŸ“¦ One Font File, Infinite Styles Normal fonts need separate files for each weight (400, 700). Variable fonts contain all weights in one file. Smaller total size, smoother transitions. πŸ“ Using Variable Fonts @font-face { font-family: ‘InterVariable’; src: url(‘InterVariable.woff2’) format(‘woff2’); font-weight: 100 900; /* Range of weights */ font-stretch: 75% 125%; /* Optional width range […]

Read More
CSS

CSS: Use New Color Functions for Dynamic Theming

- 31.05.26 - ErcanOPAK comment on CSS: Use New Color Functions for Dynamic Theming

🎨 Color Manipulation Without Preprocessors Sass had lighten(), darken(), mix(). CSS now has color-mix(), relative colors, and OKLCH. Native color functions! 🎨 color-mix() /* Mix two colors */ .hover-effect { background-color: color-mix(in srgb, blue 30%, red); } .brand-gradient { background: color-mix(in oklch, var(–primary) 50%, white); } /* Mix with transparency */ .transparent-blue { background: color-mix(in […]

Read More
CSS

CSS: Use Accent Color to Style Checkboxes and Radio Buttons

- 31.05.26 - ErcanOPAK comment on CSS: Use Accent Color to Style Checkboxes and Radio Buttons

🎨 One Line, Beautiful Checkboxes Customizing checkboxes used to require JavaScript or CSS hacks. accent-color changes their color in one line. πŸ“ Basic Usage /* Apply to all form controls */ body { accent-color: #3498db; } /* Specific controls */ input[type=’checkbox’] { accent-color: #2ecc71; } input[type=’radio’] { accent-color: #e74c3c; } input[type=’range’] { accent-color: #f39c12; } […]

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 Logical Properties for International Layouts

- 30.05.26 - ErcanOPAK comment on CSS: Use Logical Properties for International Layouts

🌍 margin-left breaks in RTL languages Arabic, Hebrew read right-to-left. CSS Logical Properties use ‘inline’ and ‘block’ instead of ‘left’ and ‘right’. Works for any language. ❌ Physical Properties .sidebar { margin-left: 20px; padding-right: 10px; text-align: left; border-left: 1px solid; } // In RTL, all these are wrong! βœ… Logical Properties .sidebar { margin-inline-start: 20px; […]

Read More
CSS

CSS: Use Scroll Snap for Smooth, Snap-to-Section Scrolling

- 29.05.26 - ErcanOPAK comment on CSS: Use Scroll Snap for Smooth, Snap-to-Section Scrolling

πŸ“± Native Scroll Snap β€” No JavaScript Horizontal carousels, full-page scroll, image galleries β€” all with CSS scroll snap. No JS, smooth physics, works everywhere. πŸ“ Full-Page Vertical Scroll Snap .container { scroll-snap-type: y mandatory; overflow-y: scroll; height: 100vh; } .section { scroll-snap-align: start; height: 100vh; } /* HTML structure */ <div class=”container”> <section class=”section”>Page […]

Read More
CSS

CSS: Use :has() Selector to Style Parent Elements Based on Children

- 28.05.26 - ErcanOPAK comment on CSS: Use :has() Selector to Style Parent Elements Based on Children

πŸ‘¨β€πŸ‘§ Parent Finally Knows About Child CSS couldn’t select parent based on children. Until now. :has() changes everything β€” style parent when child exists. ❌ Before :has() // JavaScript needed if (card.querySelector(‘.badge’)) { card.classList.add(‘has-badge’); } βœ… With :has() // Pure CSS! .card:has(.badge) { border-left: 4px solid gold; } 🎯 Powerful Examples // Style form that […]

Read More
CSS

CSS: Use CSS Variables for Theming and Dynamic Styling

- 27.05.26 - ErcanOPAK comment on CSS: Use CSS Variables for Theming and Dynamic Styling

🎨 One Variable Change, Whole Site Updates Sass variables compile once. CSS variables update at runtime. Dark mode, dynamic theming, component libraries β€” finally possible. πŸ“¦ Defining and Using Variables /* Define on :root (global) */ :root { –primary-color: #3498db; –secondary-color: #2ecc71; –spacing-unit: 8px; –border-radius: 4px; –font-size-base: 16px; } /* Use variables */ .button { […]

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: Use clamp() for Responsive Typography Without Media Queries

- 19.03.26 - ErcanOPAK comment on CSS: Use clamp() for Responsive Typography Without Media Queries

πŸ“ Fluid Typography That Just Works Writing 5 media queries for font sizes? clamp() does it in one line. Responsive typography perfected. The Old Way (Painful) h1 { font-size: 24px; } @media (min-width: 640px) { h1 { font-size: 32px; } } @media (min-width: 768px) { h1 { font-size: 40px; } } @media (min-width: 1024px) { […]

Read More
CSS

CSS: Use :has() for Parent Selectors

- 19.03.26 | 19.03.26 - ErcanOPAK comment on CSS: Use :has() for Parent Selectors

Need to style parent based on child? Impossible in CSS. Was. /* Style form if it has an error */ form:has(.error) { border: 2px solid red; } /* Style card if image is loading */ .card:has(img[loading]) { opacity: 0.5; } /* Style container if checkbox is checked */ .container:has(input:checked) { background: green; } Browser Support: […]

Read More
CSS

CSS: Use @layer to Control Cascade Order Without !important

- 19.03.26 - ErcanOPAK comment on CSS: Use @layer to Control Cascade Order Without !important

🎯 Cascade Control !important is tech debt. @layer organizes CSS priority cleanly. @layer reset, base, components, utilities; @layer reset { * { margin: 0; padding: 0; } } @layer base { body { font-family: sans-serif; } } @layer components { .button { background: blue; } } @layer utilities { .mt-4 { margin-top: 1rem; } } […]

Read More
CSS

CSS: Creating the Ultimate Glassmorphism Look (Modern UI)

- 01.03.26 - ErcanOPAK comment on CSS: Creating the Ultimate Glassmorphism Look (Modern UI)

The ‘Frosted Glass’ effect is everywhere in iOS and Windows. Here is the code to do it right. .glass-panel { background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 15px; box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37); } Note: backdrop-filter is the magic property that blurs everything […]

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: Professional Branding with Custom Scrollbars

- 28.02.26 - ErcanOPAK comment on CSS: Professional Branding with Custom Scrollbars

Default scrollbars often look ugly and clash with your design. Customize them with pure CSS. ::-webkit-scrollbar { width: 10px; } ::-webkit-scrollbar-track { background: #f1f1f1; } ::-webkit-scrollbar-thumb { background: #3498db; border-radius: 5px; } ::-webkit-scrollbar-thumb:hover { background: #2980b9; } Why? It’s a small detail that makes your web app feel ‘finished’ and high-end.

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: Creating a Maintenance-Free Theme with CSS Variables

- 28.02.26 - ErcanOPAK comment on CSS: Creating a Maintenance-Free Theme with CSS Variables

Stop hunting and replacing hex codes. Use :root variables for professional scalability. :root { –primary-color: #3498db; –spacing-unit: 1rem; } .card { padding: var(–spacing-unit); border: 2px solid var(–primary-color); } Result: To change your entire site’s branding, you only edit one line of code.

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: Use :is() and :where() to Simplify Complex Selectors

- 22.02.26 - ErcanOPAK comment on CSS: Use :is() and :where() to Simplify Complex Selectors

Writing the same selector multiple times is verbose. :is() groups them cleanly. Old Way (Verbose): header h1, header h2, header h3, footer h1, footer h2, footer h3 { color: blue; } With :is(): :is(header, footer) :is(h1, h2, h3) { color: blue; } :where() vs :is(): Same syntax, but :where() has 0 specificity (won’t override other […]

Read More
Page 6 of 9
Β« Previous 1 2 3 4 5 6 7 8 9 Next Β»

Posts pagination

« Previous 1 … 4 5 6 7 8 9 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,068)
  • Get the User Name and Domain Name from an Email Address in SQL (990)
  • How to add default value for Entity Framework migrations for DateTime and Bool (986)
  • Get the First and Last Word from a String or Sentence in SQL (865)
  • How to select distinct rows in a datatable in C# (859)
  • How to enable, disable and check if Service Broker is enabled on a database in SQL Server (661)
  • Add Constraint to SQL Table to ensure email contains @ (619)
  • Average of all values in a column that are not zero in SQL (577)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (553)
  • Find numbers with more than two decimal places in SQL (481)

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ HΔ±zΔ± Δ°zleyici Windows UygulamasΔ± v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store
  • WordPress: Fix a Navigation Block Losing Submenu Items After Sync
  • Visual Studio: Fix CodeLens Reference Counts Stuck at Stale Numbers
  • C#: Fix a UTF-8 String Literal Behaving Differently in a Switch
  • Photoshop: Fix a Liquify Mesh Snapping Back on a Smart Object
  • The AI Prompt That Turns a Crash Dump Into a Short Repro Script

Most Viewed Posts

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

Recent Posts

  • Network Speed Monitor Windows Application v2.5.1
  • Ağ HΔ±zΔ± Δ°zleyici Windows UygulamasΔ± v2.5.1
  • How to make theater mode the default for Youtube
  • The AI Prompt That Audits a Function for Thread-Safety Gaps
  • Ajax: Fix a Fetch Request Caching a Response Despite No-Store

Social

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