Note that there are some explanatory texts on larger screens.

plurals
  1. PObox-shadow and 100% Fluid Width Issue
    primarykey
    data
    text
    <p>I've been polishing up a page I built over the past day or two and have run into an issue after using box-shadow - I was hoping someone might shed some light on an easy way to fix this.</p> <p><strong>The Setup:</strong> I have a div that has a few properties, including width, max-width, and box-shadow.</p> <pre><code>#mydiv { width:100%; max-width:1200px; -webkit-box-shadow: 0px 0px 20px rgba(0, 0, 0, 1); -moz-box-shadow: 0px 0px 20px rgba(0, 0, 0, 1); box-shadow: 0px 0px 20px rgba(0, 0, 0, 1); } </code></pre> <p><strong>The Problem:</strong> The "box-shadow" property adds 40px to the width of the div element - 20px on each side. When a screen is small enough that the content should hit the 100% width attribute, we see a horizontal scroll-bar. After digging through the CSS I discovered it was because the div was technically something more like width: 100% + 40px;</p> <p><strong>What I've Tried:</strong> I've considered setting overflow:hidden on the parent div, but I do have a min-width set that would then make content inaccessible. I've also tried using a percentage for the size argument in the box-shadow CSS - 1% for example - and then setting the div's width to 98% - but the box-shadow CSS doesn't seem to accept a percentage for its size. I also have considered using javascript to test the browser width and then display or hide the box-shadow element accordingly, but it doesn't seem like the optimal solution.</p> <p>There has to be a simpler way to handle this. Thoughts?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload