Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does css border-shadow add to an element's size [duplicate]

Tags:

css

Possible Duplicate:
Is css box-shadow part of element's box model?

Does a css border-shadow property add to an element's size or is it added after and not effect other elements?

So say my div width is 100px, margin 10px, border 1px, padding 5px, box-shadow 2px, is the total width of the element 136px (inclusive of all the above) or 132px (just the first four).

like image 516
Gga Avatar asked Mar 08 '12 15:03

Gga


People also ask

How do box shadows affect Element box sizing?

Effects like box-shadow don't affect the size or the spacing.

Does border Add to width CSS?

By default in the CSS box model, the width and height you assign to an element is applied only to the element's content box. If the element has any border or padding, this is then added to the width and height to arrive at the size of the box that's rendered on the screen.

How do I keep the border from changing size in CSS?

To avoid the width or height getting increased or decreased when using CSS properties like margin , padding , etc, we can use the CSS property called box-sizing and set its value to border-box on the element in CSS.

How does CSS box shadow work?

The box-shadow property enables you to cast a drop shadow from the frame of almost any element. If a border-radius is specified on the element with a box shadow, the box shadow takes on the same rounded corners.


1 Answers

no, the shadow doesn't affect the elements size (just like an outline; read more about this here). To answer the example: your div is 132px wide.

like image 112
oezi Avatar answered Nov 15 '22 10:11

oezi