css box model

12
CSS Box Model

Upload: dhairya-joshi

Post on 15-May-2015

394 views

Category:

Education


3 download

TRANSCRIPT

Page 1: Css box model

CSS Box Model

Page 2: Css box model

The CSS box model is essentially a box that wraps around HTML elements

It consists of: ◦ margins, ◦ borders, ◦ padding, and ◦ the actual content.

Page 3: Css box model

Margin - Clears an area around the border. The margin does not have a background color, it is completely transparent

Border - A border that goes around the padding and content. The border is affected by the background color of the box

Padding - Clears an area around the content. The padding is affected by the background color of the box

Content - The content of the box, where text and images appear

Page 4: Css box model

The total width of an element should be calculated like this:

Total element width = width + left padding + right padding + left border + right border + left margin + right margin

width:220px;padding:10px;border:5px solid gray;margin:0px;

Total element width = 250 px

Page 5: Css box model

CSS Border Property

Page 6: Css box model
Page 7: Css box model

CSS Margin

Page 8: Css box model

The margin clears an area around an element (outside the border).

The margin does not have a background color, and is completely transparent.

The top, right, bottom, and left margin can be changed independently using separate properties.

Page 9: Css box model
Page 10: Css box model

CSS Padding

Page 11: Css box model

The CSS padding properties define the space between the element border and the element content.

The padding clears an area around the content (inside the border) of an element.

The padding is affected by the background color of the element.

The top, right, bottom, and left padding can be changed independently using separate properties.

Page 12: Css box model