I was processing a page that I had created in the last day or two, and ran into a problem after using box-shadow - I was hoping someone could shed some light on an easy way to fix this.
Setting: I have a div that has several properties, including width, max-width and box-shadow.
#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); }
Problem: The box-shadow property adds 40px to the width of the div element - 20px on each side. When the screen is small enough for the content to fall within the 100% width attribute, we see a horizontal scroll bar. After digging in CSS, I found that it was because the div was technically more like a width: 100% + 40px;
What I tried: I looked at overflow setting: hidden in the parent div, but I have a min-width set that will then make the content inaccessible. I also tried using a percentage for the size argument in the CSS cache shadow - for example, 1%, and then set the div width to 98%, but the CSS shadow does not accept the percentage for its size. I also considered using javascript to check the width of the browser, and then show or hide the box-shadow element appropriately, but that doesn't seem like the optimal solution.
There should be an easier way to handle this. Thoughts?
css css3 width fluid
Will D. White
source share