Nesting and Floating Elements

Slides:



Advertisements
Similar presentations
Use Tables for Layout Control Day 7. You will learn to: Understand Tables Create a Simple Table Modify Your Tables Appearance Create Page Layouts with.
Advertisements

Chapter 3 – Web Design Tables & Page Layout
Basic use of columns is to organize a list of navigation links down the left or right side of the page next to a main content area. (Fig. 1) Another common.
CSS, cont. October 12, Unit 4. Creating a Sidebar We know how to create a sidebar –Use the float property div#sidebar{ float: left; } Item1 Item2 Item3.
Cos 125 Day 24. Agenda All students meeting 7 Pm Monday, April 19 UMS Strategic Plan Assignment #7 Posted Due April 20 Two (one?) more to go Quiz Four.
MORE Cascading Style Sheets (The Positioning Model)
Purpose Tags are the key to marking up content on your HTML page. It’s the tags that mark up sections of the page and are defined (aesthetically) on the.
IMAGES Controlling size of images in CSS Aligning images in CSS Adding background images.
INFSCI  Start with a skeleton outline: copy and paste:  Warning sometimes copy and paste of quote marks from PowerPoint doesn’t work correctly.
ITP 104.  While you can do things like this:  Better to use styles instead:
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
Doman’s Sections Information in this presentation includes text and images from
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.
Web Programming Language CSS – Part 2 Dr. Ken Cosh (CSS II)
WRA HTML & CSS – BUILDING WEBPAGES. TODAY’S AGENDA Review: external stylesheets Review: transforming a list Intro: the object Intro: the.
Course created by Sarah Phillips BBCD Melbourne BAPDCOM Version 1 – April 2013.
INTRODUCTORY Tutorial 5 Using CSS for Layout and Printing.
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
Interface Design 2 Week 7. Interface Design 2 :: Week 7 :: Calendar.
Cascading Style Sheets (CSS) Part II IT210: Web-based IT.
CONTROLLING Page layout
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring 2016 CSS Positioning 1.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. September 22, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and.
Nesting and Floating. Nesting and Floating Elements To make our page content appear the way we want, and to make the best use of screen space, we can.
Ch 11 HTML and CSS Web Standards Solutions A Web Standardistas’ Approach.
Cascading Styles Sheets Positioning HTML elements.
HTML & CSS Contents: the different ways we can use to apply CSS to The HTML documents CSS Colors and Background CSS Fonts CSS Text CSS box model: padding,
Text Elements. We've already learned about the,,,, and elements. Now let's learn some elements that we'll use to present actual text content on our web.
NAVIGATION USING HTML TO SET UP THE BASIC STRUCTURE OF A NAV BAR.
Cascading Style Sheets for layout
Introduction to CSS Layout
More CSS.
Cascading Style Sheets Layout
CSS Box Model.
CSS Box Model.
CSS Box Model.
4.01 Cascading Style Sheets
Nesting and Floating.
Unit 3 - Review.
Nesting and Floating.
Floating & Positioning
Float.
Cascading Style Sheets for layout
Cascading Style Sheets (Layout)
CASCADING STYLE SHEET CSS.
Creating Layouts Using CSS
Laying out a website using CSS and HTML
Controlling Layout with Style Sheets
Positioning.
MORE Cascading Style Sheets (The Positioning Model)
Web Programming Language
CSS Box Model.
More CSS.
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.
Web Programming Language
Float.
Floating and Positioning
Web Programming Language
CSS Box Model.
Positioning.
Nesting and Floating.
Laying out Elements with CSS
Gradients.
4.01 Cascading Style Sheets
CSS Box Model.
CSS Box Model.
Gradients.
CSc 337 Lecture 5: Grid layout.
CGS 3066: Web Programming and Design Fall 2019 CSS Part 2
Presentation transcript:

Nesting and Floating Elements

Nesting <div> elements: Remember, we referred earlier to the <div> element as a "box" or "container" element. Many XHTML elements can be placed in a container, including other containers. This is known as "nesting" elements and is fairly common when building websites.

A nested <div> example: <head> <style type="text/css"> .yellow { width:400px; height:400px; background-color:yellow; } .blue { width:200px; height:200px; background-color:blue; .pink { width:100px; height:100px; background-color:pink; </style> </head> Here we have placed a container (pink) inside another container (blue), which itself is inside a parent container (yellow). <div class="yellow"> <div class="blue"> <div class="pink"></div> </div> <!-- blue --> </div> <!-- yellow --> Notice the comments added to the last two closing </div> tags. These can help us later, especially when there is a lot of code between the opening and closing tags.

Floating elements: So far, we have been building our pages vertically. Once we placed an element (such as a paragraph, image, or div) on a page, the next element automatically appeared below it on the page. To better use the real estate on a web page, we need a way to arrange elements horizontally on the page also. This is accomplished via the "float" property in CSS.

Floating <div> elements: <head> <style type="text/css"> .first { width:100px; height:100px; background-color:blue; float:left; } .second { background-color:yellow; </style> </head> More content. More content. More content. More content. More content. When we float elements, subsequent content stays at the same horizontal level and uses whatever space remains. Once that space is used up, the content will "wrap" to the beginning of the next line. <div class="first"></div> <div class="second"></div> More content.<br />

Floating right and left: <head> <style type="text/css"> .first { width:100px; height:100px; background-color:blue; float:left; } .second { background-color:yellow; float:right; </style> </head> More content. More content. More content. More content. More content. We can also float elements to both the right and left sides of the page. The subsequent content will still behave the same way, filling whatever space remains untaken by the floated elements. This is commonly done to create a web page with three columns. A navigation bar will be floated left, an information bar floated right, and the main content will reside in the middle of the page. <div class="first"></div> <div class="second"></div> More content.<br />

Clearing the float: <head> <style type="text/css"> .first { width:100px; height:100px; background-color:blue; float:left; } .second { background-color:yellow; float:right; .clearfloat { clear:both; </style> </head> More content. More content. More content. More content. More content. If we want to force the next element to start below the floated elements, we can clear the float. <div class="first"></div> <div class="second"></div> <div class="clearfloat"></div> More content.<br /> . . .