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

CSS — z-index Only Works on Positioned Elements

- 25.12.25 - ErcanOPAK comment on CSS — z-index Only Works on Positioned Elements

This is ignored: z-index: 10; ❌ Reason Element must have: position: relative | absolute | fixed | sticky  

Read More
CSS

CSS — contain Property Prevents Reflow Cascades

- 21.12.25 - ErcanOPAK comment on CSS — contain Property Prevents Reflow Cascades

.card { contain: layout paint; } Why this is huge Stops layout recalculation spreading Massive UI performance win on large pages

Read More
CSS

position: sticky Stops Working Because of Parents

- 19.12.25 - ErcanOPAK comment on position: sticky Stops Working Because of Parents

Sticky fails if any parent has: overflow: hidden; 🧠 Fix Remove overflow or move sticky element higher.

Read More
CSS

will-change Can Make Performance Worse

- 17.12.25 - ErcanOPAK comment on will-change Can Make Performance Worse

will-change: transform; ❌ Overuse causes: GPU memory pressure Slower rendering ✅ Rule Apply only shortly before animation, remove after.

Read More
CSS

overflow-x: hidden Is Not a Layout Fix

- 17.12.25 - ErcanOPAK comment on overflow-x: hidden Is Not a Layout Fix

Using this hides bugs instead of fixing them. ✅ Proper Fix Identify overflowing element Fix width or flex behavior

Read More
CSS

100vh Breaks Mobile Layouts — Here’s Why

- 16.12.25 - ErcanOPAK comment on 100vh Breaks Mobile Layouts — Here’s Why

Mobile browsers resize viewport dynamically. ✅ Fix height: 100svh; or JS-calculated height.

Read More
CSS

CSS position: sticky Not Working? Here’s Why

- 15.12.25 - ErcanOPAK comment on CSS position: sticky Not Working? Here’s Why

Sticky fails when parent has: overflow: hidden; ✅ Fix Remove overflow or move sticky element higher in the DOM. Sticky only works inside scrollable ancestors.

Read More
CSS

CSS opacity Breaks Child Elements — Use RGBA Instead

- 14.12.25 - ErcanOPAK comment on CSS opacity Breaks Child Elements — Use RGBA Instead

❌ .card { opacity: 0.8; } This also fades text and icons. ✅ .card { background-color: rgba(0,0,0,0.8); } Why Opacity affects the entire element tree.

Read More
CSS

CSS 100vh Is Broken on Mobile (Real Fix)

- 13.12.25 - ErcanOPAK comment on CSS 100vh Is Broken on Mobile (Real Fix)

height: 100vh breaks on mobile browsers. ✅ Correct Solution height: 100dvh; Or fallback: min-height: -webkit-fill-available; Why Mobile address bars change viewport height dynamically.

Read More
CSS

CSS “Text Overflow Ellipsis Not Working” — The Missing Combo

- 12.12.25 - ErcanOPAK comment on CSS “Text Overflow Ellipsis Not Working” — The Missing Combo

Most devs do only: text-overflow: ellipsis; But it requires three rules: overflow: hidden; white-space: nowrap; text-overflow: ellipsis; 💡 Add max-width too for perfect control.

Read More
CSS / HTML

HTML5 “Broken Autofill Styles” — Chrome’s Yellow Background Bug

- 11.12.25 - ErcanOPAK comment on HTML5 “Broken Autofill Styles” — Chrome’s Yellow Background Bug

Chrome applies weird autofill yellow color using a shadow DOM style. ✔ Fix input:-webkit-autofill { -webkit-box-shadow: 0 0 0 1000px white inset; } 💡 Works for: light themes dark themes password inputs

Read More
CSS

CSS “Z-Index Doesn’t Work!” — The Parent Stacking Context Curse

- 11.12.25 - ErcanOPAK comment on CSS “Z-Index Doesn’t Work!” — The Parent Stacking Context Curse

The REAL reason z-index fails: A parent has position + z-index→ it creates a new stacking context. ✔ Fix Remove z-index from parent OR apply a higher z-index to the parent itself. 💡 Debug Trick Apply: outline: 2px solid red; To visualize stacking contexts.

Read More
CSS

CSS “Absolute Element Misaligned” — The position: relative Curse

- 09.12.25 - ErcanOPAK comment on CSS “Absolute Element Misaligned” — The position: relative Curse

Absolute positioned child needs a positioned parent. ❌ Wrong .parent { } .child { position: absolute; top: 10px; } ✔ Correct .parent { position: relative; } .child { position: absolute; top: 10px; } 💡 Hidden Trap Transforms also create new positioning contexts.

Read More
CSS

CSS Grid “Overflow Bug” — When Your Layout Randomly Breaks

- 08.12.25 - ErcanOPAK comment on CSS Grid “Overflow Bug” — When Your Layout Randomly Breaks

If a grid child is bigger than the track → grid collapses. ✔ Life-Saving Fix Add: min-width: 0; min-height: 0; ⚠ Why? CSS Grid defaults are NOT zero — they try to preserve content size.This breaks responsive layouts.

Read More
CSS

CSS Flexbox Gap Not Working? — The Hidden Flex Wrapping Trap

- 07.12.25 - ErcanOPAK comment on CSS Flexbox Gap Not Working? — The Hidden Flex Wrapping Trap

gap: only works when flex items wrap correctly. ❌ Wrong .container { display: flex; gap: 20px; flex-wrap: nowrap; } ✔ Correct .container { display: flex; flex-wrap: wrap; gap: 20px; } 💡 Hidden Detail Safari had partial support — updating fixes 90% layout bugs.

Read More
CSS

CSS Z-Index Hell — Why Elements Randomly Disappear (and the Real Fix)

- 06.12.25 - ErcanOPAK comment on CSS Z-Index Hell — Why Elements Randomly Disappear (and the Real Fix)

Z-index doesn’t work the way most devs think.It depends on stacking contexts, not numbers. 🔥 The Real Causes position: relative creates a new stacking context transform creates a new stacking context opacity < 1 creates a new stacking context Parent stacking contexts override children You can set z-index: 999999 and STILL not see your element. […]

Read More
CSS

CSS Subgrid — The Most Misunderstood Layout Feature

- 06.12.25 - ErcanOPAK comment on CSS Subgrid — The Most Misunderstood Layout Feature

Most devs don’t know that Grid can inherit layout from its parent grid. .child { display: grid; grid-template-columns: subgrid; } 🔥 Why It’s Huge Perfect alignment between parent & child Cleaner responsive layouts No duplicated breakpoints Layout consistency made easy

Read More
CSS

CSS Container Queries — The Future of Responsive Design

- 06.12.25 | 06.12.25 - ErcanOPAK comment on CSS Container Queries — The Future of Responsive Design

Media queries scale by viewport…Container queries scale by component. .card { container-type: inline-size; } @container (min-width: 450px) { .card { flex-direction: row; } } ✨ Why They’re a Big Deal 🎯 Component-level responsiveness 📦 No more giant breakpoint spaghetti 🧩 Perfect for design systems

Read More
CSS

How to display HTML components on the same line in CSS

- 27.10.23 - ErcanOPAK comment on How to display HTML components on the same line in CSS

Let’s say we have 3 buttons and we want to show them on the same line: #outer { width:100%; text-align: center; } .inner { display: inline-block; } <div id=”outer”> <div class=”inner”><button type=”submit” class=”msgBtn” onClick=”return false;” >Save</button></div> <div class=”inner”><button type=”submit” class=”msgBtn2″ onClick=”return false;”>Publish</button></div> <div class=”inner”><button class=”msgBtnBack”>Back</button></div> </div>  

Read More
ASP.Net MVC / ASP.Net WebForms / Bootstrap / CSS

How to add some content to the right side of CardHeader on Bootstrap

- 21.06.23 | 21.06.23 - ErcanOPAK comment on How to add some content to the right side of CardHeader on Bootstrap

<div class=”card-header container-fluid”> <div class=”col-md-10″><h3>Your Header Title</h3></div> <div class=”col-md-2 float-right”>The content you want to add to the right side.</div> </div>  

Read More
ASP.Net MVC / ASP.Net WebForms / CSS / HTML

How to align inconsistently sized logos with CSS

- 04.12.22 | 04.12.22 - ErcanOPAK comment on How to align inconsistently sized logos with CSS

These 3 lines will save you (fit, line up, remove background): aspect-ratio: 3/2; object-fit: contain; mix-blend-mode:color-burn; Let’s see how you can use that: In the body section, we have a div with the “photoDiv” class. <div class=”photoDiv”> <img src=”1.png”> <img src=”2.png”> <img src=”3.png”> <img src=”4.png”> <img src=”5.png”> </div> And here is the magical CSS: <style> […]

Read More
CSS

How to disable mouse actions for a specific div with CSS

- 15.09.22 - ErcanOPAK comment on How to disable mouse actions for a specific div with CSS

Let’s say you have a div with id “myDiv” <div id=”myDiv”> <input type=”text” value=”value” /> <br /> <textarea>value</textarea> </div> If you want to disable all the mouse actions in that div only then you can use this in your CSS file: #myDiv { pointer-events: none; }  

Read More
ASP.Net MVC / ASP.Net WebForms / CSS / HTML

How to apply two classes to a single element in CSS

- 15.09.22 - ErcanOPAK comment on How to apply two classes to a single element in CSS

Let’s say you want to use 2 or more classes for a div. Then you should use these classes inside the class attribute, separated by whitespace: <div class=”myFirstClass mySecondClass”></div> To target elements that contain all of the specified classes, use this CSS selector (no space) in your CSS file: .myFirstClass.mySecondClass {}  

Read More
ASP.Net MVC / ASP.Net WebForms / CSS

How to change the style of scrollbar with CSS

- 03.07.22 - ErcanOPAK comment on How to change the style of scrollbar with CSS

::-webkit-scrollbar { width: 12px; } ::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); border-radius: 10px; } ::-webkit-scrollbar-thumb { border-radius: 10px; -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); } You can get more detail from here.

Read More
ASP.Net MVC / ASP.Net WebForms / CSS

How to add scroll bar to div in Asp.Net

- 03.07.22 - ErcanOPAK comment on How to add scroll bar to div in Asp.Net

Let’s say we have div in view <div id=”myDiv” class=”div-with-scrollbar”> </div> With this CSS file, you can add a scrollbar .div-with-scrollbar { overflow-y: scroll; width: 100%; height: 500px; }  

Read More
CSS

Hide element in CSS with Display and Visibility

- 30.10.21 - ErcanOPAK comment on Hide element in CSS with Display and Visibility

visibility: hidden (Hide but keep the space) <div stlye=”visibility: hidden;”>The Components We want to Hide</div> By default, the value of the visibility property is visible. However, if you want to make an image invisible, you can set the value of visibility to hidden.   display: none (Hide and remove the space) <div stlye=”display: none;”>The Components We want to Hide</div> The display […]

Read More
CSS

CSS Padding and Margin 4 Values and What happens if some of them are omitted

- 18.11.19 | 23.11.19 - ErcanOPAK comment on CSS Padding and Margin 4 Values and What happens if some of them are omitted

CSS Padding The CSS padding properties are used to generate space around an element’s content, inside of any defined borders.

Read More
CSS

How to override a CSS Property

- 18.11.19 | 22.11.19 - ErcanOPAK comment on How to override a CSS Property

The !important property in CSS is used to provide more weight (importance) than normal property. In CSS, the !important means that “this is important”, ignore all the subsequent rules, and apply !important rule and the !important keyword must be placed at the end of the line, immediately before the semicolon. In other words, it adds importance to […]

Read More
ASP.Net WebForms / CSS / HTML

Imitating a blink tag with CSS3 animations

- 13.06.18 | 22.11.19 - ErcanOPAK comment on Imitating a blink tag with CSS3 animations

Chrome and Safari don’t support or even CSS’s text-decoration: blink;, but here is the solution for BLINK: <style type=”text/css”> .blink { animation: blink 1s steps(5, start) infinite; -webkit-animation: blink 1s steps(5, start) infinite; } @keyframes blink { to { visibility: hidden; } } @-webkit-keyframes blink { to { visibility: hidden; } } </style> This is […]

Read More
Page 3 of 3
« Previous 1 2 3

Posts pagination

« Previous 1 2 3
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 (865)
  • Get the First and Last Word from a String or Sentence in SQL (837)
  • How to select distinct rows in a datatable in C# (806)
  • 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 (534)
  • How to use Map Mode for Vertical Scroll Mode in Visual Studio (491)
  • Find numbers with more than two decimal places in SQL (449)

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 (865)
  • Get the First and Last Word from a String or Sentence in SQL (837)
  • How to select distinct rows in a datatable in C# (806)
  • 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