SlideShare a Scribd company logo
14
THINKING INSIDE THE BOX
OVERVIEW
• The parts of an
element box
• Box dimensions
• Padding
• Borders
• Outlines
• Margins
• Display roles
• Drop shadows
The Parts of an Element Box
NOTE: The margin is indicated with a blue shade and
outline, but is invisible in the layout.
Specifying Box Dimensions
width
Values: Length, percentage, auto
height
Values: Length, percentage, auto
Specify the dimensions of an element box with width and
height properties
Box Sizing Models
box-sizing
Values: content-box, border-box
There are two methods for sizing an element box, specified with
the box-sizing attribute:
Content-box sizing (default)
Applies width and height values to the content box only
Border-box sizing
Applies width and height values to the border box (including
the padding and content)
Box Sizing Models Compared
Overflow
overflow
Values: visible, hidden, scroll, auto
Specifies what to do when content doesn’t fit in a sized element box:
Padding
padding, padding-top, padding-right,
padding-bottom, padding-left
Values: Length, percentage
An amount of space between the content area and the border (or
the space the border would be if one isn’t specified).
You can add padding to one side at a time, or on all sides with
the padding shorthand property.
Padding (cont’d)
blockquote {
padding-top: 2em;
padding-right: 4em;
padding-bottom: 2em;
padding-left: 4em;
background-color: #D098D4; /*light green*/
}
Shorthand padding Property
The padding property adds space around 1, 2, 3, or 4 sides of
the content using the clockwise top, right, bottom, left (TRouBLe)
order:
padding: top right bottom left;
padding: 2em 4em 2em 4em;
(this shorthand produces the same result as the example on the
previous slide)
Shorthand padding Property (cont’d)
If the left and right sides are the same, you can omit the last
value, and the second value will be applied on both the left and
right sides:
padding: top right+left bottom;
padding: 2em 4em 2em;
(this shorthand produces the same result as the examples on the
two previous slides)
Shorthand padding Property (cont’d)
If the top and and bottom sides are also the same, you can omit the
third value, and the first value will be applied on both the top and
bottom:
padding: top+bottom right+left;
padding: 2em 4em;
(same result as previous examples)
If all sides are the same, provide one value, and it’s applied to all
sides:
padding: all sides;
padding: 2em;
(2em padding all around)
Borders
• A border is a line drawn around the content area and its
(optional) padding.
• The thickness of the border is included in the dimensions of
the element box.
• You define style, width (thickness), and color for borders.
• Borders can be applied to single sides or all around
Border Style
border-style,
border-top-style, border-right-style,
border-bottom-style, border-left-style
Values: none, solid,
hidden, dotted, dashed,
double, groove, ridge,
inset, outset
NOTE: The default is none,
so if you don’t define a
border style, it won’t
appear.
Border Style
border-style
The border-style shorthand uses the clockwise (TRouBLe)
shorthand order. The following rules have the same effect:
div#silly {
border-top-style: solid;
border-right-style: dashed;
border-bottom-style: double;
border-left-style: dotted;
width: 300px;
height: 100px;
}
div#silly {
border-style: solid dashed double dotted;
}
Border Width
border-width,
border-top-width, border-right-width,
border-bottom-width, border-left-width
Values: Length, thin, medium, thick
The border-width shorthand uses the clockwise (TRouBLe)
order:
div#help {
border-width: thin medium thick 12px;
border-style: solid;
width: 300px;
height: 100px;
}
NOTE: The border-style property is
required for the border to be rendered.
Border Color
border-color,
border-top-color, border-right-color,
border-bottom-color, border-left-color
Values: Color value (named or numeric)
The border-color properties override the color property:
div#special {
border-color: maroon aqua;
border-style: solid;
border-width: 6px;
width: 300px;
height: 100px;
}
NOTE: The border-style property is
required for the border to be rendered.
Border Shorthand Properties
border,
border-top, border-right,
border-bottom, border-left
Values: border-style border-width border-color
Combine style, width, and color values in shorthand properties
for each side or all around (border):
p.example {
border: 2px dotted aqua;
}
NOTE: The border-style property must be included in the shorthand for
the border to be rendered.
Border Radius (Rounded Corners)
border-radius
Values: 1, 2, 3, or 4 length or percentage values
• The border-radius property rounds off the corners of an
element.
• The value is a length or percentage value reflecting the radius
of the curve.
• Providing one value makes all the corners the same.
• Four values are applied clockwise, starting from the top-left
corner.
Border Radius (cont’d)
Margins
margin, margin-top, margin-right,
margin-bottom, margin-left
Values: Length, percentage
The margin is an amount of space added on the outside of the
border. They keep elements from bumping into one another or
the edge of the viewport.
The shorthand margin property works the same as the
padding shorthand. Values are applied clockwise (TRouBLe
order) and are repeated if fewer than 4 values are supplied.
Margins (cont’d)
A p#A {
margin: 4em;
border: 2px solid red;
background: #e2f3f5;
}
B p#B {
margin-top: 2em;
margin-right: 250px;
margin-bottom: 1em;
margin-left: 4em;
border: 2px solid red;
background: #e2f3f5;
}
C body {
margin: 0 20%;
border: 3px solid red;
background-color: #e2f3f5;
}
Margins (cont’d)
Top and bottom margins of neighboring elements collapse
(they overlap instead of accumulating).
The top element has a bottom margin of 4em. The bottom
element has a top margin of 2em. The resulting margin is 4em
(the largest value).
Assigning Display Types
display
Values: inline | block | run-in | flex | grid | flow | flow-root | list-item | table
| table-row-group | table-header-group | table-footer-group | table-row | table-cell
| table-column-group | table-column | table-caption | ruby | ruby-base | ruby-text |
ruby-base-container | ruby-text-container | inline-block | inline-table | inline-flex
| inline-grid | contents | none
Assigns a display type that determines how the element box behaves in
layouts.
Examples:
• Make li (normally block elements) into inline elements so they line up in a
horizontal menu: nav li { display: inline; }
• Make an anchor (a) element (normally inline) display as a block so you can
give it a width and height: nav li a { display: block; }
Box Drop Shadows
box-shadow
Values: horizontal-offset vertical-offset blur-distance spread-
distance color inset, none
Applies a drop shadow around the visible element box.
The values are a horizontal and vertical offset, optional blur
and spread values (in pixels), a color value, and the option to
make it appear inset.
Box Drop Shadows (cont’d)
A box-shadow: 6px 6px gray;
B box-shadow: 6px 6px 5px gray; /* 5 pixel blur */
C box-shadow: 6px 6px 5px 10px gray; /* 5px blur,10px spread */

More Related Content

What's hot

jQuery
jQueryjQuery
jQuery
Vishwa Mohan
 
Java Script Object Notation (JSON)
Java Script Object Notation (JSON)Java Script Object Notation (JSON)
Java Script Object Notation (JSON)
Adnan Sohail
 
Javascript
JavascriptJavascript
Javascript
Sun Technlogies
 
Html table
Html tableHtml table
Html table
JayjZens
 
Bootstrap
BootstrapBootstrap
Bootstrap
Jadson Santos
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
veena parihar
 
HTML 5 Canvas & SVG
HTML 5 Canvas & SVGHTML 5 Canvas & SVG
HTML 5 Canvas & SVG
Ofir's Fridman
 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)
GOPAL BASAK
 
Bootstrap 5 whats new
Bootstrap 5   whats newBootstrap 5   whats new
Bootstrap 5 whats new
Sandun Perera
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
Eliran Eliassy
 
jQuery
jQueryjQuery
jQuery
Jay Poojara
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
Võ Duy Tuấn
 
CSS3 2D/3D transform
CSS3 2D/3D transformCSS3 2D/3D transform
CSS3 2D/3D transformKenny Lee
 
Css position
Css positionCss position
Css position
Webtech Learning
 
Introduction to JSON
Introduction to JSONIntroduction to JSON
Introduction to JSON
Kanda Runapongsa Saikaew
 
Flutter tutorial for Beginner Step by Step
Flutter tutorial for Beginner Step by StepFlutter tutorial for Beginner Step by Step
Flutter tutorial for Beginner Step by Step
Chandramouli Biyyala
 

What's hot (20)

jQuery
jQueryjQuery
jQuery
 
Java Script Object Notation (JSON)
Java Script Object Notation (JSON)Java Script Object Notation (JSON)
Java Script Object Notation (JSON)
 
Javascript
JavascriptJavascript
Javascript
 
Intr To Html & Xhtml
Intr To Html & XhtmlIntr To Html & Xhtml
Intr To Html & Xhtml
 
Html table
Html tableHtml table
Html table
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
 
Css properties
Css propertiesCss properties
Css properties
 
Css Ppt
Css PptCss Ppt
Css Ppt
 
CSS Lists and Tables
CSS Lists and TablesCSS Lists and Tables
CSS Lists and Tables
 
HTML 5 Canvas & SVG
HTML 5 Canvas & SVGHTML 5 Canvas & SVG
HTML 5 Canvas & SVG
 
Document Object Model (DOM)
Document Object Model (DOM)Document Object Model (DOM)
Document Object Model (DOM)
 
Bootstrap 5 whats new
Bootstrap 5   whats newBootstrap 5   whats new
Bootstrap 5 whats new
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
jQuery
jQueryjQuery
jQuery
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
 
CSS3 2D/3D transform
CSS3 2D/3D transformCSS3 2D/3D transform
CSS3 2D/3D transform
 
Css position
Css positionCss position
Css position
 
Introduction to JSON
Introduction to JSONIntroduction to JSON
Introduction to JSON
 
Flutter tutorial for Beginner Step by Step
Flutter tutorial for Beginner Step by StepFlutter tutorial for Beginner Step by Step
Flutter tutorial for Beginner Step by Step
 

Similar to Chapter 14: Box Model

CSS tutorial chapter 2
CSS tutorial chapter 2CSS tutorial chapter 2
CSS tutorial chapter 2
jeweltutin
 
Introduction to CSS Borders - Lesson 4
Introduction to CSS Borders - Lesson 4Introduction to CSS Borders - Lesson 4
Introduction to CSS Borders - Lesson 4
Naresh Sharma
 
Border
BorderBorder
Border
Ankit Dubey
 
Cascading style sheets (CSS-Web Technology)
Cascading style sheets (CSS-Web Technology)Cascading style sheets (CSS-Web Technology)
Cascading style sheets (CSS-Web Technology)
Timbal Mayank
 
Dimensions of elements.pdf
Dimensions of elements.pdfDimensions of elements.pdf
CSS Topic wise Short notes ppt by Navya.E
CSS Topic wise Short notes ppt by Navya.ECSS Topic wise Short notes ppt by Navya.E
CSS Topic wise Short notes ppt by Navya.E
NavyaEnugala
 
Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3
Gheyath M. Othman
 
CSS Box Model
CSS Box ModelCSS Box Model
CSS Box Model
kjkleindorfer
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
Css3 Complete Reference
Css3 Complete ReferenceCss3 Complete Reference
Css3 Complete Reference
EPAM Systems
 
Layouts
Layouts Layouts
Layouts
kjkleindorfer
 
Web - CSS 1.pptx
Web - CSS 1.pptxWeb - CSS 1.pptx
Web - CSS 1.pptx
haroon451422
 
Unit - 3 CSS(Cascading Style Sheet).pptx
Unit - 3 CSS(Cascading Style Sheet).pptxUnit - 3 CSS(Cascading Style Sheet).pptx
Unit - 3 CSS(Cascading Style Sheet).pptx
kushwahanitesh592
 
css3.pptx
css3.pptxcss3.pptx
css3.pptx
ThiyaguPappu
 
IT2255 Web Essentials - Unit II Web Designing
IT2255 Web Essentials - Unit II  Web DesigningIT2255 Web Essentials - Unit II  Web Designing
IT2255 Web Essentials - Unit II Web Designing
pkaviya
 

Similar to Chapter 14: Box Model (20)

CSS tutorial chapter 2
CSS tutorial chapter 2CSS tutorial chapter 2
CSS tutorial chapter 2
 
Introduction to CSS Borders - Lesson 4
Introduction to CSS Borders - Lesson 4Introduction to CSS Borders - Lesson 4
Introduction to CSS Borders - Lesson 4
 
Pres
PresPres
Pres
 
Border
BorderBorder
Border
 
Css
CssCss
Css
 
Cascading style sheets (CSS-Web Technology)
Cascading style sheets (CSS-Web Technology)Cascading style sheets (CSS-Web Technology)
Cascading style sheets (CSS-Web Technology)
 
Dimensions of elements.pdf
Dimensions of elements.pdfDimensions of elements.pdf
Dimensions of elements.pdf
 
Css3
Css3Css3
Css3
 
CSS Topic wise Short notes ppt by Navya.E
CSS Topic wise Short notes ppt by Navya.ECSS Topic wise Short notes ppt by Navya.E
CSS Topic wise Short notes ppt by Navya.E
 
Css borders
Css bordersCss borders
Css borders
 
Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 3
 
CSS Box Model
CSS Box ModelCSS Box Model
CSS Box Model
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
 
Css3 Complete Reference
Css3 Complete ReferenceCss3 Complete Reference
Css3 Complete Reference
 
Layouts
Layouts Layouts
Layouts
 
Web - CSS 1.pptx
Web - CSS 1.pptxWeb - CSS 1.pptx
Web - CSS 1.pptx
 
Unit - 3 CSS(Cascading Style Sheet).pptx
Unit - 3 CSS(Cascading Style Sheet).pptxUnit - 3 CSS(Cascading Style Sheet).pptx
Unit - 3 CSS(Cascading Style Sheet).pptx
 
css3.pptx
css3.pptxcss3.pptx
css3.pptx
 
IT2255 Web Essentials - Unit II Web Designing
IT2255 Web Essentials - Unit II  Web DesigningIT2255 Web Essentials - Unit II  Web Designing
IT2255 Web Essentials - Unit II Web Designing
 
Css class-02
Css class-02Css class-02
Css class-02
 

More from Steve Guinan

Chapter 18: Transitions, Transforms, and Animation
Chapter 18: Transitions, Transforms, and AnimationChapter 18: Transitions, Transforms, and Animation
Chapter 18: Transitions, Transforms, and Animation
Steve Guinan
 
Chapter 17: Responsive Web Design
Chapter 17: Responsive Web DesignChapter 17: Responsive Web Design
Chapter 17: Responsive Web Design
Steve Guinan
 
Chapter 9: Forms
Chapter 9: FormsChapter 9: Forms
Chapter 9: Forms
Steve Guinan
 
Chapter 8: Tables
Chapter 8: TablesChapter 8: Tables
Chapter 8: Tables
Steve Guinan
 
Chapter 12: CSS Part 2
Chapter 12: CSS Part 2Chapter 12: CSS Part 2
Chapter 12: CSS Part 2
Steve Guinan
 
Chapter 11: Intro to CSS
Chapter 11: Intro to CSSChapter 11: Intro to CSS
Chapter 11: Intro to CSS
Steve Guinan
 
Chapter 23: Web Images
Chapter 23: Web ImagesChapter 23: Web Images
Chapter 23: Web Images
Steve Guinan
 
Chapter 7: Images
Chapter 7: ImagesChapter 7: Images
Chapter 7: Images
Steve Guinan
 
HubSpot Student Instructions
HubSpot Student InstructionsHubSpot Student Instructions
HubSpot Student Instructions
Steve Guinan
 
Ch 6: Links
Ch 6: LinksCh 6: Links
Ch 6: Links
Steve Guinan
 
Ch 5: Marking up Text
Ch 5: Marking up TextCh 5: Marking up Text
Ch 5: Marking up Text
Steve Guinan
 
Ch 3: Big Concepts
Ch 3: Big ConceptsCh 3: Big Concepts
Ch 3: Big Concepts
Steve Guinan
 
Ch 2: How the Web Works
Ch 2: How the Web WorksCh 2: How the Web Works
Ch 2: How the Web Works
Steve Guinan
 
Ch 1: Getting Started
Ch 1: Getting StartedCh 1: Getting Started
Ch 1: Getting Started
Steve Guinan
 
Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7
Steve Guinan
 
Intro to Web Design 6e Chapter 6
Intro to Web Design 6e Chapter 6Intro to Web Design 6e Chapter 6
Intro to Web Design 6e Chapter 6
Steve Guinan
 
Intro to Web Design 6e Chapter 5
Intro to Web Design 6e Chapter 5Intro to Web Design 6e Chapter 5
Intro to Web Design 6e Chapter 5
Steve Guinan
 
Intro to Web Design 6e Chapter 4
Intro to Web Design 6e Chapter 4 Intro to Web Design 6e Chapter 4
Intro to Web Design 6e Chapter 4
Steve Guinan
 
Intro to Web Design 6e Chapter 3
Intro to Web Design 6e Chapter 3 Intro to Web Design 6e Chapter 3
Intro to Web Design 6e Chapter 3
Steve Guinan
 
Intro to Web Design 6e Chapter 2
Intro to Web Design 6e Chapter 2 Intro to Web Design 6e Chapter 2
Intro to Web Design 6e Chapter 2
Steve Guinan
 

More from Steve Guinan (20)

Chapter 18: Transitions, Transforms, and Animation
Chapter 18: Transitions, Transforms, and AnimationChapter 18: Transitions, Transforms, and Animation
Chapter 18: Transitions, Transforms, and Animation
 
Chapter 17: Responsive Web Design
Chapter 17: Responsive Web DesignChapter 17: Responsive Web Design
Chapter 17: Responsive Web Design
 
Chapter 9: Forms
Chapter 9: FormsChapter 9: Forms
Chapter 9: Forms
 
Chapter 8: Tables
Chapter 8: TablesChapter 8: Tables
Chapter 8: Tables
 
Chapter 12: CSS Part 2
Chapter 12: CSS Part 2Chapter 12: CSS Part 2
Chapter 12: CSS Part 2
 
Chapter 11: Intro to CSS
Chapter 11: Intro to CSSChapter 11: Intro to CSS
Chapter 11: Intro to CSS
 
Chapter 23: Web Images
Chapter 23: Web ImagesChapter 23: Web Images
Chapter 23: Web Images
 
Chapter 7: Images
Chapter 7: ImagesChapter 7: Images
Chapter 7: Images
 
HubSpot Student Instructions
HubSpot Student InstructionsHubSpot Student Instructions
HubSpot Student Instructions
 
Ch 6: Links
Ch 6: LinksCh 6: Links
Ch 6: Links
 
Ch 5: Marking up Text
Ch 5: Marking up TextCh 5: Marking up Text
Ch 5: Marking up Text
 
Ch 3: Big Concepts
Ch 3: Big ConceptsCh 3: Big Concepts
Ch 3: Big Concepts
 
Ch 2: How the Web Works
Ch 2: How the Web WorksCh 2: How the Web Works
Ch 2: How the Web Works
 
Ch 1: Getting Started
Ch 1: Getting StartedCh 1: Getting Started
Ch 1: Getting Started
 
Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7Intro to Web Design 6e Chapter 7
Intro to Web Design 6e Chapter 7
 
Intro to Web Design 6e Chapter 6
Intro to Web Design 6e Chapter 6Intro to Web Design 6e Chapter 6
Intro to Web Design 6e Chapter 6
 
Intro to Web Design 6e Chapter 5
Intro to Web Design 6e Chapter 5Intro to Web Design 6e Chapter 5
Intro to Web Design 6e Chapter 5
 
Intro to Web Design 6e Chapter 4
Intro to Web Design 6e Chapter 4 Intro to Web Design 6e Chapter 4
Intro to Web Design 6e Chapter 4
 
Intro to Web Design 6e Chapter 3
Intro to Web Design 6e Chapter 3 Intro to Web Design 6e Chapter 3
Intro to Web Design 6e Chapter 3
 
Intro to Web Design 6e Chapter 2
Intro to Web Design 6e Chapter 2 Intro to Web Design 6e Chapter 2
Intro to Web Design 6e Chapter 2
 

Recently uploaded

Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
JungkooksNonexistent
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Sanjeev Rampal
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
laozhuseo02
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
laozhuseo02
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
nirahealhty
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
ShahulHameed54211
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
TristanJasperRamos
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
natyesu
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
Arif0071
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
Gal Baras
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
3ipehhoa
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
Rogerio Filho
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
Himani415946
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
3ipehhoa
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
3ipehhoa
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
JeyaPerumal1
 

Recently uploaded (16)

Latest trends in computer networking.pptx
Latest trends in computer networking.pptxLatest trends in computer networking.pptx
Latest trends in computer networking.pptx
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shopHistory+of+E-commerce+Development+in+China-www.cfye-commerce.shop
History+of+E-commerce+Development+in+China-www.cfye-commerce.shop
 
This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!This 7-second Brain Wave Ritual Attracts Money To You.!
This 7-second Brain Wave Ritual Attracts Money To You.!
 
Output determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CCOutput determination SAP S4 HANA SAP SD CC
Output determination SAP S4 HANA SAP SD CC
 
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptxLiving-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
Living-in-IT-era-Module-7-Imaging-and-Design-for-Social-Impact.pptx
 
BASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptxBASIC C++ lecture NOTE C++ lecture 3.pptx
BASIC C++ lecture NOTE C++ lecture 3.pptx
 
test test test test testtest test testtest test testtest test testtest test ...
test test  test test testtest test testtest test testtest test testtest test ...test test  test test testtest test testtest test testtest test testtest test ...
test test test test testtest test testtest test testtest test testtest test ...
 
How to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptxHow to Use Contact Form 7 Like a Pro.pptx
How to Use Contact Form 7 Like a Pro.pptx
 
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
原版仿制(uob毕业证书)英国伯明翰大学毕业证本科学历证书原版一模一样
 
guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...guildmasters guide to ravnica Dungeons & Dragons 5...
guildmasters guide to ravnica Dungeons & Dragons 5...
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
急速办(bedfordhire毕业证书)英国贝德福特大学毕业证成绩单原版一模一样
 
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
1比1复刻(bath毕业证书)英国巴斯大学毕业证学位证原版一模一样
 
1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...1.Wireless Communication System_Wireless communication is a broad term that i...
1.Wireless Communication System_Wireless communication is a broad term that i...
 

Chapter 14: Box Model

  • 2. OVERVIEW • The parts of an element box • Box dimensions • Padding • Borders • Outlines • Margins • Display roles • Drop shadows
  • 3. The Parts of an Element Box NOTE: The margin is indicated with a blue shade and outline, but is invisible in the layout.
  • 4. Specifying Box Dimensions width Values: Length, percentage, auto height Values: Length, percentage, auto Specify the dimensions of an element box with width and height properties
  • 5. Box Sizing Models box-sizing Values: content-box, border-box There are two methods for sizing an element box, specified with the box-sizing attribute: Content-box sizing (default) Applies width and height values to the content box only Border-box sizing Applies width and height values to the border box (including the padding and content)
  • 6. Box Sizing Models Compared
  • 7. Overflow overflow Values: visible, hidden, scroll, auto Specifies what to do when content doesn’t fit in a sized element box:
  • 8. Padding padding, padding-top, padding-right, padding-bottom, padding-left Values: Length, percentage An amount of space between the content area and the border (or the space the border would be if one isn’t specified). You can add padding to one side at a time, or on all sides with the padding shorthand property.
  • 9. Padding (cont’d) blockquote { padding-top: 2em; padding-right: 4em; padding-bottom: 2em; padding-left: 4em; background-color: #D098D4; /*light green*/ }
  • 10. Shorthand padding Property The padding property adds space around 1, 2, 3, or 4 sides of the content using the clockwise top, right, bottom, left (TRouBLe) order: padding: top right bottom left; padding: 2em 4em 2em 4em; (this shorthand produces the same result as the example on the previous slide)
  • 11. Shorthand padding Property (cont’d) If the left and right sides are the same, you can omit the last value, and the second value will be applied on both the left and right sides: padding: top right+left bottom; padding: 2em 4em 2em; (this shorthand produces the same result as the examples on the two previous slides)
  • 12. Shorthand padding Property (cont’d) If the top and and bottom sides are also the same, you can omit the third value, and the first value will be applied on both the top and bottom: padding: top+bottom right+left; padding: 2em 4em; (same result as previous examples) If all sides are the same, provide one value, and it’s applied to all sides: padding: all sides; padding: 2em; (2em padding all around)
  • 13. Borders • A border is a line drawn around the content area and its (optional) padding. • The thickness of the border is included in the dimensions of the element box. • You define style, width (thickness), and color for borders. • Borders can be applied to single sides or all around
  • 14. Border Style border-style, border-top-style, border-right-style, border-bottom-style, border-left-style Values: none, solid, hidden, dotted, dashed, double, groove, ridge, inset, outset NOTE: The default is none, so if you don’t define a border style, it won’t appear.
  • 15. Border Style border-style The border-style shorthand uses the clockwise (TRouBLe) shorthand order. The following rules have the same effect: div#silly { border-top-style: solid; border-right-style: dashed; border-bottom-style: double; border-left-style: dotted; width: 300px; height: 100px; } div#silly { border-style: solid dashed double dotted; }
  • 16. Border Width border-width, border-top-width, border-right-width, border-bottom-width, border-left-width Values: Length, thin, medium, thick The border-width shorthand uses the clockwise (TRouBLe) order: div#help { border-width: thin medium thick 12px; border-style: solid; width: 300px; height: 100px; } NOTE: The border-style property is required for the border to be rendered.
  • 17. Border Color border-color, border-top-color, border-right-color, border-bottom-color, border-left-color Values: Color value (named or numeric) The border-color properties override the color property: div#special { border-color: maroon aqua; border-style: solid; border-width: 6px; width: 300px; height: 100px; } NOTE: The border-style property is required for the border to be rendered.
  • 18. Border Shorthand Properties border, border-top, border-right, border-bottom, border-left Values: border-style border-width border-color Combine style, width, and color values in shorthand properties for each side or all around (border): p.example { border: 2px dotted aqua; } NOTE: The border-style property must be included in the shorthand for the border to be rendered.
  • 19. Border Radius (Rounded Corners) border-radius Values: 1, 2, 3, or 4 length or percentage values • The border-radius property rounds off the corners of an element. • The value is a length or percentage value reflecting the radius of the curve. • Providing one value makes all the corners the same. • Four values are applied clockwise, starting from the top-left corner.
  • 21. Margins margin, margin-top, margin-right, margin-bottom, margin-left Values: Length, percentage The margin is an amount of space added on the outside of the border. They keep elements from bumping into one another or the edge of the viewport. The shorthand margin property works the same as the padding shorthand. Values are applied clockwise (TRouBLe order) and are repeated if fewer than 4 values are supplied.
  • 22. Margins (cont’d) A p#A { margin: 4em; border: 2px solid red; background: #e2f3f5; } B p#B { margin-top: 2em; margin-right: 250px; margin-bottom: 1em; margin-left: 4em; border: 2px solid red; background: #e2f3f5; } C body { margin: 0 20%; border: 3px solid red; background-color: #e2f3f5; }
  • 23. Margins (cont’d) Top and bottom margins of neighboring elements collapse (they overlap instead of accumulating). The top element has a bottom margin of 4em. The bottom element has a top margin of 2em. The resulting margin is 4em (the largest value).
  • 24. Assigning Display Types display Values: inline | block | run-in | flex | grid | flow | flow-root | list-item | table | table-row-group | table-header-group | table-footer-group | table-row | table-cell | table-column-group | table-column | table-caption | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | inline-block | inline-table | inline-flex | inline-grid | contents | none Assigns a display type that determines how the element box behaves in layouts. Examples: • Make li (normally block elements) into inline elements so they line up in a horizontal menu: nav li { display: inline; } • Make an anchor (a) element (normally inline) display as a block so you can give it a width and height: nav li a { display: block; }
  • 25. Box Drop Shadows box-shadow Values: horizontal-offset vertical-offset blur-distance spread- distance color inset, none Applies a drop shadow around the visible element box. The values are a horizontal and vertical offset, optional blur and spread values (in pixels), a color value, and the option to make it appear inset.
  • 26. Box Drop Shadows (cont’d) A box-shadow: 6px 6px gray; B box-shadow: 6px 6px 5px gray; /* 5 pixel blur */ C box-shadow: 6px 6px 5px 10px gray; /* 5px blur,10px spread */