THE BOX MODEL Putting layouts together with CSS. The Box Model  How would you describe a box?  Container?  Tags or elements are “containers”  puts.

Slides:



Advertisements
Similar presentations
LIS650 lecture 4 Thomas Krichel today CSS Properties –Box properties-- List properties –Table properties-- Classification properties –(Audio.
Advertisements

LIS650 lecture 4 Thomas Krichel today Advice CSS Properties –Box properties –List properties –Classification properties Fun with selectors.
Copenhagen, 6 December 2004 Modern CSS Principles Miruna Bădescu Finsiel Romania.
CSS Layout Crash Course An Advance CSS Tutorial. Inline vs. Block Many HTML elements have a default display setting of Block. Block elements take up the.
Part 5 Introduction to CSS. CSS Display - Block and Inline Elements A block element is an element that takes up the full width available, and has a line.
With CSS, a color is most often specified by: a HEX value - like "#ff0000" an RGB value - like "rgb(255,0,0)" a color name - like "red“ Example h1.
CIS 1310 – HTML & CSS 6 Layout. CIS 1310 – HTML & CSS Learning Outcomes  Describe & Apply the CSS Box Model  Configure Float with CSS  Designate Positioning.
© 2010, Robert K. Moniot Chapter 5 CSS : Cascading Style Sheets 1.
9-May-15 More CSS. 2 A different emphasis CSS is the same for XML as it is for HTML and XHTML, but-- XML contains no display information If you want your.
CS4370/6370 Web Development Cascading Style Sheets (CSS)
Cascading Style Sheets SP.772 May 6, CSS Useful for creating one unified look for an entire web site. Helps to seperate style from content. Can.
Web Design & Development Cascading Style Sheets (CSS)
Lecture 6 8/11/11.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
MORE Cascading Style Sheets (The Positioning Model)
14-Jul-15 CSS Applications to XML. 2 A different emphasis CSS is the same for XML as it is for HTML, but-- HTML already does a pretty good job of layout.
Advanced CSS - Page Layout. Advanced CSS  Compound Selectors:  Is a Dreamweaver term, not a CSS term.  Describes more advanced types of selectors such.
1Computer Sciences Department. And use
Cascading Style Sheets CSS. CSS Positioning Normal Flow Top -> bottom | left -> right Arranged in the order they appear in the code make room for one.
Cascading Style Sheets CSS. div … Used like a container to group content Gives context to the elements in the grouping Give it a descriptive name with.
CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.
1 Cascading Style Sheets (CSS) Part 2. 2 The Sources of Style Sheets.
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
Copyright © Terry Felke-Morris CSS Flow & Positioning 1 Copyright © Terry Felke-Morris.
CSS Netcentric. What is CSS O CSS stands for Cascading Style Sheets O Styles define how to display HTML elements O Styles were added to HTML 4.0 to solve.
CSS = Cascading Style Sheet CSS consists of rules to display, style and decorate HTML elements Why CSS ? – Separate decoration from HTML markup (Ex :,,…)
Svetlin Nakov Telerik Corporation
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
Cascading Style Sheets Eugenia Fernandez IUPUI. CSS Purpose CSS allow you to specify the style in which your XML elements are displayed. CSS were originally.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.
1 CS428 Web Engineering Lecture 08 Border, Margin, Padding … (CSS - III)
Cascading Style Sheets Positioning Controls Visibility.
CSS Fun damentals The Document Hierarchy Element Relationships The Box Model.
INTRODUCTORY Tutorial 5 Using CSS for Layout and Printing.
Cascading Style Sheets Positioning Controls Visibility.
Tutorial 4 Creating Page Layouts with CSS
IN THE DOCUMENT OBJECT MODEL, EACH LINE OF HTML IS AN ELEMENT (AN OBJECT), ABLE TO HAVE ATTRIBUTES, PROPERTIES AND VALUES. CSS TELLS THE BROWSER HOW TO.
- WE’LL LOOK AT THE POSITION PROPERTY AND HOW CSS RESOLVES CONFLICTS BETWEEN STYLING INSTRUCTIONS The position property; CSS specificity hierarchy.
Today’s objectives  Announcements  Positioning  Measurement units.
Understanding CSS Cascading Style Sheets control the presentation of content in HTML pages Style Sheets separate formatting from the content –Styles defined.
Chapter 7.  Change body and link styles  Create a drop-down menu  Change color and font styles in the menu  Create a pop-up effect using CSS  Utilize.
Mimi Opkins.  One of the major benefits of using CSS is that you’re not forced to lay your sites out in tables.  The layout possibilities of CSS give.
Laying out Elements with CSS
Cascading Style Sheets Boxes
CSS Layouts CH 13.
Cascading Style Sheets™ (CSS)
CSS Layouts: Grouping Elements
Webpage layout using CSS
Cascading Style Sheets
Floating & Positioning
Putting Things Where We Want Them
CSS Applications to XML 19-Sep-18.
Objectives Create a reset style sheet Explore page layout designs
Controlling Layout with Style Sheets
Second CSS Lecture Applications to XML
Positioning.
MORE Cascading Style Sheets (The Positioning Model)
Float Property Elements that seem to “float" on the right or left side of either the browser window or another element are often configured using.
Cascading Style Sheets
More CSS 22-Feb-19.
Floating and Positioning
Positioning.
Positioning.
Cascading Style Sheets
CSS Applications to XML 20-May-19.
The div Element and CSS for layout
CSS Applications to XML 3-Jul-19.
Cascading Style Sheets™ (CSS)
Positioning Boxes Using CSS
Presentation transcript:

THE BOX MODEL Putting layouts together with CSS

The Box Model  How would you describe a box?  Container?  Tags or elements are “containers”  puts the text it contains into paragraph form.

Box Model content edge or inner edge The content edge surrounds the element's rendered content.rendered content padding edge The padding edge surrounds the box padding. If the padding has 0 width, the padding edge is the same as the content edge. The padding edge of a box defines the edges of the containing block established by the box. containing block border edge The border edge surrounds the box's border. If the border has 0 width, the border edge is the same as the padding edge. margin edge or outer edge The margin edge surrounds the box margin. If the margin has 0 width, the margin edge is the same as the border edge. The perimeter of each of the four areas (content, padding, border, and margin) is called an "edge", so each box has 4 edges:

Box Model diagram

Example in Class  Applying the Box model  Adding an image  Floating  Note some differences between Firefox and IE  Useful for seeing the immediate results rycss_text-indent rycss_text-indent

Box Model properties  Padding  Negative values  CSS shorthand: top right bottom left  Margin  Border

dimension  Width  Height

Positioning  The Positioning properties allow you to specify the left, right, top, and bottom position of an element.  It also allows you to set the shape of an element, place an element behind another, and to specify what should happen when an element's content is too big to fit in a specified area.

Normal Flow  Default behavior of a web browser  Rendered according to what order the elements (like and are listed in the html.doc)  Example with float

Positioning: Four Ways of Placing  Static  Absolute  Relative  Fixed

position: static;  Static positioning is simply placing a box in the normal flow.  Default behavior of an unpositioned box  Rarely used except to override anotehr rule

position: absolute  NOT in the normal flow  Positioned relative to the element that contains it.  (if there is no element, it will be positioned relative to the tag)

position: relative;  Positioned to the normal flow  Relative to original position

position: fixed;  Relative to browser, not containing block.  Pulls out of the normal flow.  “carved into rock”  Wont resize

Positioning properties

Floating  In the normal flow  Allows text to flow around the box.  Can’t be manipulated like other positioned boxes with left: 20; etc.

Floating boxes  Determines where object is relative to the parent flow. selector { float: right ; } Possible values: left | right | top | bottom | inside | outside | start | end | none

Floating p { width: 24em } #l1 { float: left; width: 8em; height: 3em } #l2 { float: left; width: 4em; height: 6em } #r1 { float: right; width: 6em; height: 9em } #l3 { float: left; width: 7em; height: 9em } #r2 { float: right; width: 3em; height: 5em }

Length Units  {margin-right: 24px }  The number can be an integer or a decimal fraction, and can be preceded by + or -.  Units can be absolute or relative:  Absolute: mm, cm, in, pt, pc (millimeters, centimeters, inches, points, picas)  Relative: em, ex, px (the element's font height, the element's x-height, pixels)

Z-index  Z-index is used to specify the stacking order of the positionable elements.  The number value may be positive or negative, but MUST be an integer.  Default z-ordering of elements in a document is back-to-front in the order of their appearance in the HTML.  An element with property z-index: 3 is going to overlap a z-index:1

Overflow  Scroll  Auto  Hidden  Visible p{ overflow: auto; width: 200px; height: 300px; }

IE, i.e. “headache”  Box model discrepancies.  CSS Standards determine that  “width” = width of content  IE versions before 6 see it differently  “width” = padding+border+width of content

Box Model Hack: IE hack  The name says it all. Just remove the padding/borders from the problem box, nest a second box inside the first, and put the padding/borders and the content within that nested box. End of problem. It looks like this if you are using two divs:  div { width: 100px; } div.i { padding: 1em; } Text  If used while you have two nestled elements anyway, then the only negative effect of this solution (a single extra div in the HTML) is a non-issue. The major benefit of this method is that it works just about everywhere.

Validating your CSS  uri.html uri.html