SlideShare una empresa de Scribd logo
1 de 57
Descargar para leer sin conexión
Web Design Principles
5th Edition
Chapter Six
Using the CSS Box Model
Objectives
When you complete this chapter, you will be able to:
• Understand the CSS visual formatting model
• Use the CSS box model
• Apply the margin properties
• Apply the padding properties
• Apply the border properties
• Use the page layout box properties
• Create a simple page layout
2Web Design Principles 5th Ed.
The CSS Visual Formatting Model
The CSS Visual Formatting Model
• Describes how the element content boxes should
be displayed by the browser
• Based on the hierarchical structure of the HTML
document and element display type
• Elements fall into three display type categories
– Block (e.g., paragraphs): block elements contain
inline boxes that contain element content
– Inline: contain the content within the block-level
elements; they do not form new blocks of content
– List-item: create a surrounding containing box and
list-item inline boxes
Web Design Principles 5th Ed. 4
5Web Design Principles 5th Ed.
Specifying the Display Type
• The CSS display property determines the display
type of an element
• You can create block-level, inline, and list type
elements
• The display property is often used to create
horizontal navigation lists:
li {
display: inline;
list-style-type: none;
}
6Web Design Principles 5th Ed.
7Web Design Principles 5th Ed.
Using the CSS Box Model
Using the CSS Box Model
• Describes the rectangular boxes that contain content on
a Web page
• Each block-level element created is displayed as a box
containing content in the browser window
• Each content box can have margins, borders, and
padding (specified individually)
9Web Design Principles 5th Ed.
10Web Design Principles 5th Ed.
11
p {
margin: 2em;
padding: 2em;
border: solid thin black;
background-color: white;
}
Web Design Principles 5th Ed.
12Web Design Principles 5th Ed.
13
p {
background-color: white;
border-left: 6px solid;
margin-left: 2em;
margin-top: 3em;
padding-top: 2em;
padding-right: 2em;
padding-bottom: 1em;
padding-left: 1em;
}
Web Design Principles 5th Ed.
Measurement Values
• The margin, border, and padding properties
allow two types of measurement:
– Length
• Absolute or relative values
– Percentage
• Based on width of containing box
14Web Design Principles 5th Ed.
Applying the Margin Properties
Applying the Margin Properties
• Margins are always transparent
• Margins enhance the legibility of your text
• You can specify either a length or percentage value
• The following style rule sets all margins to 2 em
p {margin: 2em;}
• You can specify settings for individual margins
p {
margin-left: 2em;
margin-right: 3em;
}
16Web Design Principles 5th Ed.
17Web Design Principles 5th Ed.
Negative Margins
• Negative margins can be set to achieve special
effects
• You an override the default browser margin by
setting a negative value
p {margin-left: -10px;}
• Can also be used to remove the default margins
from other elements
18Web Design Principles 5th Ed.
19Web Design Principles 5th Ed.
Collapsing Margins
• To ensure spacing is consistent, the browser will
collapse vertical margins between elements
• By default, browser selects the greater of the two
margins (top and bottom)
20Web Design Principles 5th Ed.
21Web Design Principles 5th Ed.
Zeroing Margins
• To remove the default margin spacing in the
browser, set margin values to zero
body {margin: 0; padding: 0;}
• If you zero margins for the entire page, you must
explicitly set margins for individual elements
22Web Design Principles 5th Ed.
23Web Design Principles 5th Ed.
Applying the Padding Properties
Applying the Padding Properties
• Control the padding area in the box model
– Area between the element content and the border
• Padding area inherits the background color of the
element
• There are five padding properties:
– padding
– padding-top
– padding-right
– padding-bottom
– padding-left
25Web Design Principles 5th Ed.
26Web Design Principles 5th Ed.
27Web Design Principles 5th Ed.
Applying the Border Properties
Applying the Border Properties
• Control the appearance of element borders
– Border displays between the margin and the padding
• There are five basic border properties:
– border
– border-top
– border-right
– border-bottom
– border-left
• A typical border style rule:
border {solid thin black}
29Web Design Principles 5th Ed.
30Web Design Principles 5th Ed.
Specifying Border Style
Border style keywords:
• none — no border on the element (default)
• dotted — dotted border
• dashed — dashed border
• solid — solid line border
• double — double line border
• groove — 3D embossed border
• ridge — 3D outward extended border
• inset — 3D inset border (entire box)
• outset — 3D outset (entire box)
• dot-dash — alternating dots and dashes (CSS3 value)
• dot-dot-dash — two dots and a dash (CSS3 value)
• wavy — wavy line border (CSS3 value)
31Web Design Principles 5th Ed.
32Web Design Principles 5th Ed.
Specifying Border Width
• Allows setting border width with either a
keyword or a length value
• You can use the following keywords to express
width:
– thin
– medium (default)
– thick
33Web Design Principles 5th Ed.
34Web Design Principles 5th Ed.
Specifying Border Color
• The border color property lets you set the color of
the element border
• The value can be hexadecimal RGB or a color
name
35Web Design Principles 5th Ed.
Using the Border Shorthand Syntax
• The border property lets you state the
properties for all four borders of an element
– You can state the border-width, border-style, and
border-color in any order
• The following rule sets the border-style to solid
− The border-weight is 1 pixel; the border color is red
p {border: solid 1px red;}
36Web Design Principles 5th Ed.
Specifying Rounded Borders
• The CSS3 border radius property lets you create
rounded borders
• This is a CSS3 property that is not yet supported
by all browsers
37Web Design Principles 5th Ed.
38Web Design Principles 5th Ed.
Specifying Rounded Borders
• The following rule sets the radius for all four
corners to 1em:
border-radius: 1em;
• You can also use individual properties to set each
corner as shown
border-top-right-radius: 3em;
border-top-left-radius: 3em;
border-bottom-right-radius: 1em;
border-bottom-left-radius: 1em;
39Web Design Principles 5th Ed.
Using the Page Layout Box
Properties
Using the Page Layout Box
Properties
• These properties let you control the dimensions
and position of content boxes
• These properties are essential to building CSS
page layouts
• This section covers the following box properties
• width, min-width, max-width
• height, min-height, max-height
• float
• clear
• overflow
41Web Design Principles 5th Ed.
Setting Element Width
• You can set the horizontal width of an element
using either a length value or percentage
• For fixed layouts, use pixels
• For flexible layouts, use percentages
42Web Design Principles 5th Ed.
43Web Design Principles 5th Ed.
Calculating Box Model Width
• The witdh you specify applies to the content only,
not the entire element
• The actual element width is the result of adding the
padding border and margin to the content width
44Web Design Principles 5th Ed.
45Web Design Principles 5th Ed.
Setting Element Height
• Height property lets you set the vertical height of an
element
• Normally the content should determine the height
of the element
• Height is useful when you need to create a box
with specific dimensions
div {height: 150px; width: 300px;}
46Web Design Principles 5th Ed.
Floating Elements
• The float property lets you position an element to
the left or right edge of its containing element
• You can float an image or content box to the left or
right of text
47Web Design Principles 5th Ed.
48Web Design Principles 5th Ed.
49Web Design Principles 5th Ed.
Floating Elements
• #float {
• width: 200px;
• float: left;
• border: 1px solid black;
• padding-bottom: 20px;
• margin: 0px 20px 10px 10px;
• text-align: center;
• background-color: #cfc;
• }
50Web Design Principles 5th Ed.
Clearing Elements
• The clear property lets you control the flow of text
around floated elements
• Clear is only used when you’re floating an element
• Use the clear property to force text beneath a
floated element rather than next to it
51Web Design Principles 5th Ed.
52Web Design Principles 5th Ed.
Controlling the Overflow
• The overflow property lets you control when
content overflows the content box that contains it
• This can happen when the content is larger than
the area that contains it
• Using the height property is the most common
cause of overflow problems
53Web Design Principles 5th Ed.
54Web Design Principles 5th Ed.
Creating Box Shadows
• Box shadow property lets you add shadows to
create a 3D effect
• This is a CSS3 property that is not evenly
supported by all browsers
• You set both horizontal and vertical measurement
and color for the shadowed edges of the box
p {
margin: 2em;
border: thin solid;
box-shadow: .5em .5em #ccc;
padding: 1em;
}
55Web Design Principles 5th Ed.
56Web Design Principles 5th Ed.
Summary
• The CSS box model lets you control spacing around
elements
• You can set margin, border and padding values for all
four sides of the box
• For flexible layouts, choose relative length units
• For fixed pages, choose pixel measurements
• The page layout box properties let you create floating
content boxes and wrap text around images
• Remember to use margin, border, and padding
properties to enhance legibility
57Web Design Principles 5th Ed.

Más contenido relacionado

La actualidad más candente

Chapter 17: Responsive Web Design
Chapter 17: Responsive Web DesignChapter 17: Responsive Web Design
Chapter 17: Responsive Web DesignSteve Guinan
 
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon BaltimoreCreating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon BaltimoreSuzanne Dergacheva
 
Creating a Reusable Drupal Website for Higher Education - Webinar
Creating a Reusable Drupal Website for Higher Education - WebinarCreating a Reusable Drupal Website for Higher Education - Webinar
Creating a Reusable Drupal Website for Higher Education - WebinarSuzanne Dergacheva
 
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech DayCreating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech DaySuzanne Dergacheva
 
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon DublinCreating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon DublinSuzanne Dergacheva
 
Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflowPeter Kaizer
 
Responsive web design
Responsive web designResponsive web design
Responsive web designRicha Goel
 
OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?Michael Posso
 
MCC Web Design Workshop
MCC Web Design WorkshopMCC Web Design Workshop
MCC Web Design WorkshopFaye Tandog
 

La actualidad más candente (19)

Ppt ch02
Ppt ch02Ppt ch02
Ppt ch02
 
Ppt ch02
Ppt ch02Ppt ch02
Ppt ch02
 
Ppt ch01
Ppt ch01Ppt ch01
Ppt ch01
 
Ppt ch09
Ppt ch09Ppt ch09
Ppt ch09
 
Chapter 17: Responsive Web Design
Chapter 17: Responsive Web DesignChapter 17: Responsive Web Design
Chapter 17: Responsive Web Design
 
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon BaltimoreCreating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon Baltimore
 
Creating a Reusable Drupal Website for Higher Education - Webinar
Creating a Reusable Drupal Website for Higher Education - WebinarCreating a Reusable Drupal Website for Higher Education - Webinar
Creating a Reusable Drupal Website for Higher Education - Webinar
 
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech DayCreating a Reusable Drupal Website for Higher Education - at USG Tech Day
Creating a Reusable Drupal Website for Higher Education - at USG Tech Day
 
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon DublinCreating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon Dublin
 
Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflow
 
Slides bootstrap-4
Slides bootstrap-4Slides bootstrap-4
Slides bootstrap-4
 
Ppt ch07
Ppt ch07Ppt ch07
Ppt ch07
 
Html,CSS & UI/UX design
Html,CSS & UI/UX designHtml,CSS & UI/UX design
Html,CSS & UI/UX design
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
 
OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?OOCSS, SMACSS or BEM?
OOCSS, SMACSS or BEM?
 
Html 5
Html 5Html 5
Html 5
 
Theming in React
Theming in ReactTheming in React
Theming in React
 
Ui devopler
Ui devoplerUi devopler
Ui devopler
 
MCC Web Design Workshop
MCC Web Design WorkshopMCC Web Design Workshop
MCC Web Design Workshop
 

Destacado

Destacado (11)

Dilek Oluklu - CV
Dilek Oluklu - CVDilek Oluklu - CV
Dilek Oluklu - CV
 
Box Model and Page Layouts
Box Model and Page LayoutsBox Model and Page Layouts
Box Model and Page Layouts
 
The Box Model [CSS Introduction]
The Box Model [CSS Introduction]The Box Model [CSS Introduction]
The Box Model [CSS Introduction]
 
CSS Box Model
CSS Box ModelCSS Box Model
CSS Box Model
 
CSS Box Model Presentation
CSS Box Model PresentationCSS Box Model Presentation
CSS Box Model Presentation
 
Floating
FloatingFloating
Floating
 
Laying Out Elements with CSS
Laying Out Elements with CSSLaying Out Elements with CSS
Laying Out Elements with CSS
 
Css floats
Css floatsCss floats
Css floats
 
CSS Layouting #4 : Float
CSS Layouting #4 : FloatCSS Layouting #4 : Float
CSS Layouting #4 : Float
 
Css Ppt
Css PptCss Ppt
Css Ppt
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 

Similar a Ppt ch06

Similar a Ppt ch06 (20)

9781111528705_PPT_ch05.ppt
9781111528705_PPT_ch05.ppt9781111528705_PPT_ch05.ppt
9781111528705_PPT_ch05.ppt
 
Ppt ch05
Ppt ch05Ppt ch05
Ppt ch05
 
CSS tutorial chapter 2
CSS tutorial chapter 2CSS tutorial chapter 2
CSS tutorial chapter 2
 
9781111528705_PPT_ch07.ppt
9781111528705_PPT_ch07.ppt9781111528705_PPT_ch07.ppt
9781111528705_PPT_ch07.ppt
 
9781111528705_PPT_ch08.ppt
9781111528705_PPT_ch08.ppt9781111528705_PPT_ch08.ppt
9781111528705_PPT_ch08.ppt
 
Ppt ch08
Ppt ch08Ppt ch08
Ppt ch08
 
9781111528705_PPT_ch04.ppt
9781111528705_PPT_ch04.ppt9781111528705_PPT_ch04.ppt
9781111528705_PPT_ch04.ppt
 
9781111528705_PPT_ch10.ppt
9781111528705_PPT_ch10.ppt9781111528705_PPT_ch10.ppt
9781111528705_PPT_ch10.ppt
 
Web development basics (Part-2)
Web development basics (Part-2)Web development basics (Part-2)
Web development basics (Part-2)
 
Dangerous CSS
Dangerous CSSDangerous CSS
Dangerous CSS
 
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptx
 
Ppt ch04
Ppt ch04Ppt ch04
Ppt ch04
 
CSS and CSS3
CSS and CSS3CSS and CSS3
CSS and CSS3
 
Dimensions of elements.pdf
Dimensions of elements.pdfDimensions of elements.pdf
Dimensions of elements.pdf
 
Website development using dreamweaver
Website development using dreamweaverWebsite development using dreamweaver
Website development using dreamweaver
 
Frames.ppt
Frames.pptFrames.ppt
Frames.ppt
 
Krishan gaurav-sapient bootstrapsession
Krishan gaurav-sapient bootstrapsessionKrishan gaurav-sapient bootstrapsession
Krishan gaurav-sapient bootstrapsession
 
The Future of CSS Layout
The Future of CSS LayoutThe Future of CSS Layout
The Future of CSS Layout
 
MTA managing the graphical interface by using css
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using css
 
css3.pptx
css3.pptxcss3.pptx
css3.pptx
 

Último

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 

Último (20)

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 

Ppt ch06

  • 1. Web Design Principles 5th Edition Chapter Six Using the CSS Box Model
  • 2. Objectives When you complete this chapter, you will be able to: • Understand the CSS visual formatting model • Use the CSS box model • Apply the margin properties • Apply the padding properties • Apply the border properties • Use the page layout box properties • Create a simple page layout 2Web Design Principles 5th Ed.
  • 3. The CSS Visual Formatting Model
  • 4. The CSS Visual Formatting Model • Describes how the element content boxes should be displayed by the browser • Based on the hierarchical structure of the HTML document and element display type • Elements fall into three display type categories – Block (e.g., paragraphs): block elements contain inline boxes that contain element content – Inline: contain the content within the block-level elements; they do not form new blocks of content – List-item: create a surrounding containing box and list-item inline boxes Web Design Principles 5th Ed. 4
  • 6. Specifying the Display Type • The CSS display property determines the display type of an element • You can create block-level, inline, and list type elements • The display property is often used to create horizontal navigation lists: li { display: inline; list-style-type: none; } 6Web Design Principles 5th Ed.
  • 8. Using the CSS Box Model
  • 9. Using the CSS Box Model • Describes the rectangular boxes that contain content on a Web page • Each block-level element created is displayed as a box containing content in the browser window • Each content box can have margins, borders, and padding (specified individually) 9Web Design Principles 5th Ed.
  • 11. 11 p { margin: 2em; padding: 2em; border: solid thin black; background-color: white; } Web Design Principles 5th Ed.
  • 13. 13 p { background-color: white; border-left: 6px solid; margin-left: 2em; margin-top: 3em; padding-top: 2em; padding-right: 2em; padding-bottom: 1em; padding-left: 1em; } Web Design Principles 5th Ed.
  • 14. Measurement Values • The margin, border, and padding properties allow two types of measurement: – Length • Absolute or relative values – Percentage • Based on width of containing box 14Web Design Principles 5th Ed.
  • 15. Applying the Margin Properties
  • 16. Applying the Margin Properties • Margins are always transparent • Margins enhance the legibility of your text • You can specify either a length or percentage value • The following style rule sets all margins to 2 em p {margin: 2em;} • You can specify settings for individual margins p { margin-left: 2em; margin-right: 3em; } 16Web Design Principles 5th Ed.
  • 18. Negative Margins • Negative margins can be set to achieve special effects • You an override the default browser margin by setting a negative value p {margin-left: -10px;} • Can also be used to remove the default margins from other elements 18Web Design Principles 5th Ed.
  • 20. Collapsing Margins • To ensure spacing is consistent, the browser will collapse vertical margins between elements • By default, browser selects the greater of the two margins (top and bottom) 20Web Design Principles 5th Ed.
  • 22. Zeroing Margins • To remove the default margin spacing in the browser, set margin values to zero body {margin: 0; padding: 0;} • If you zero margins for the entire page, you must explicitly set margins for individual elements 22Web Design Principles 5th Ed.
  • 24. Applying the Padding Properties
  • 25. Applying the Padding Properties • Control the padding area in the box model – Area between the element content and the border • Padding area inherits the background color of the element • There are five padding properties: – padding – padding-top – padding-right – padding-bottom – padding-left 25Web Design Principles 5th Ed.
  • 28. Applying the Border Properties
  • 29. Applying the Border Properties • Control the appearance of element borders – Border displays between the margin and the padding • There are five basic border properties: – border – border-top – border-right – border-bottom – border-left • A typical border style rule: border {solid thin black} 29Web Design Principles 5th Ed.
  • 31. Specifying Border Style Border style keywords: • none — no border on the element (default) • dotted — dotted border • dashed — dashed border • solid — solid line border • double — double line border • groove — 3D embossed border • ridge — 3D outward extended border • inset — 3D inset border (entire box) • outset — 3D outset (entire box) • dot-dash — alternating dots and dashes (CSS3 value) • dot-dot-dash — two dots and a dash (CSS3 value) • wavy — wavy line border (CSS3 value) 31Web Design Principles 5th Ed.
  • 33. Specifying Border Width • Allows setting border width with either a keyword or a length value • You can use the following keywords to express width: – thin – medium (default) – thick 33Web Design Principles 5th Ed.
  • 35. Specifying Border Color • The border color property lets you set the color of the element border • The value can be hexadecimal RGB or a color name 35Web Design Principles 5th Ed.
  • 36. Using the Border Shorthand Syntax • The border property lets you state the properties for all four borders of an element – You can state the border-width, border-style, and border-color in any order • The following rule sets the border-style to solid − The border-weight is 1 pixel; the border color is red p {border: solid 1px red;} 36Web Design Principles 5th Ed.
  • 37. Specifying Rounded Borders • The CSS3 border radius property lets you create rounded borders • This is a CSS3 property that is not yet supported by all browsers 37Web Design Principles 5th Ed.
  • 39. Specifying Rounded Borders • The following rule sets the radius for all four corners to 1em: border-radius: 1em; • You can also use individual properties to set each corner as shown border-top-right-radius: 3em; border-top-left-radius: 3em; border-bottom-right-radius: 1em; border-bottom-left-radius: 1em; 39Web Design Principles 5th Ed.
  • 40. Using the Page Layout Box Properties
  • 41. Using the Page Layout Box Properties • These properties let you control the dimensions and position of content boxes • These properties are essential to building CSS page layouts • This section covers the following box properties • width, min-width, max-width • height, min-height, max-height • float • clear • overflow 41Web Design Principles 5th Ed.
  • 42. Setting Element Width • You can set the horizontal width of an element using either a length value or percentage • For fixed layouts, use pixels • For flexible layouts, use percentages 42Web Design Principles 5th Ed.
  • 44. Calculating Box Model Width • The witdh you specify applies to the content only, not the entire element • The actual element width is the result of adding the padding border and margin to the content width 44Web Design Principles 5th Ed.
  • 46. Setting Element Height • Height property lets you set the vertical height of an element • Normally the content should determine the height of the element • Height is useful when you need to create a box with specific dimensions div {height: 150px; width: 300px;} 46Web Design Principles 5th Ed.
  • 47. Floating Elements • The float property lets you position an element to the left or right edge of its containing element • You can float an image or content box to the left or right of text 47Web Design Principles 5th Ed.
  • 50. Floating Elements • #float { • width: 200px; • float: left; • border: 1px solid black; • padding-bottom: 20px; • margin: 0px 20px 10px 10px; • text-align: center; • background-color: #cfc; • } 50Web Design Principles 5th Ed.
  • 51. Clearing Elements • The clear property lets you control the flow of text around floated elements • Clear is only used when you’re floating an element • Use the clear property to force text beneath a floated element rather than next to it 51Web Design Principles 5th Ed.
  • 53. Controlling the Overflow • The overflow property lets you control when content overflows the content box that contains it • This can happen when the content is larger than the area that contains it • Using the height property is the most common cause of overflow problems 53Web Design Principles 5th Ed.
  • 55. Creating Box Shadows • Box shadow property lets you add shadows to create a 3D effect • This is a CSS3 property that is not evenly supported by all browsers • You set both horizontal and vertical measurement and color for the shadowed edges of the box p { margin: 2em; border: thin solid; box-shadow: .5em .5em #ccc; padding: 1em; } 55Web Design Principles 5th Ed.
  • 57. Summary • The CSS box model lets you control spacing around elements • You can set margin, border and padding values for all four sides of the box • For flexible layouts, choose relative length units • For fixed pages, choose pixel measurements • The page layout box properties let you create floating content boxes and wrap text around images • Remember to use margin, border, and padding properties to enhance legibility 57Web Design Principles 5th Ed.