Floating and Positioning

Slides:



Advertisements
Similar presentations
15 LAYOUT Controlling the position of elements Creating site layouts Designing for different sized screens.
Advertisements

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.
Advance CSS (Menu and Layout) Miftahul Huda. CSS Navigation MENU It's truly remarkable what can be achieved through CSS, especially with navigation menus.
Floating Elements CS380.
Tutorial 4: Creating page layout with css
Today’s objectives Site performance Padding, Margins, Borders
Using CSS for Page Layout. Types of HTML Elements Block-Level Element –Creates blocks of content e.g. div, h1..h6, p, ul, ol, li, table, form –They start.
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.
Using HTML Tables.
MORE Cascading Style Sheets (The Positioning Model)
1 The Structure of a Web Table beginning of the table structure first row of three in the table end of the table structure table cells You do not need.
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Advanced CSS - Page Layout. Advanced CSS  Compound Selectors:  Is a Dreamweaver term, not a CSS term.  Describes more advanced types of selectors such.
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.
Copyright © Terry Felke-Morris CSS Flow & Positioning 1 Copyright © Terry Felke-Morris.
Neal Stublen Course Road Map  Create web page layouts using CSS  Manage CSS  Test website validity  Create navigation menus using.
Designing a Web Page with Tables. A text table: contains only text, evenly spaced on the Web page in rows and columns uses only standard word processing.
Svetlin Nakov Telerik Corporation
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.
Internet Technology Dr Jing LU Updated Dr Violet Snell / Dr Kalin Penev 1 Internet Technology (week 6)  Recap: Validating HTML  Page Layout.
CSS Layout Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  float & clear  display & visibility.
Eric Meyer on CSS Project 12 pp Project 12 Files.
Cascading Style Sheets (CSS) Part II IT210: Web-based IT.
CSS Positioning & Layout Creating layouts and controlling elements.
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.
Understanding CSS Cascading Style Sheets control the presentation of content in HTML pages Style Sheets separate formatting from the content –Styles defined.
Ch 11 HTML and CSS Web Standards Solutions A Web Standardistas’ Approach.
CHAPTER 15 Floating and Positioning. FLOAT VS. POSITION  Floating an element moves it to the left or right, allowing the following text to wrap around.
CSCI N241: Fundamentals of Web Design Copyright ©2006  Department of Computer & Information Science Using CSS for Absolute Layouts.
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.
Cascading Style Sheets for layout
Laying out Elements with CSS
Cascading Style Sheets Layout
CSS Layouts: Positioning and Navbars
CSS Layouts: Grouping Elements
Webpage layout using CSS
Floating & Positioning
Advanced CSS BIS1523 – Lecture 20.
Cascading Style Sheets for layout
Cascading Style Sheets (Layout)
Putting Things Where We Want Them
Programming the Web using XHTML and JavaScript
The Internet 10/25/11 XHTML Tables
CSS Applications to XML 19-Sep-18.
PAGE LAYOUT - 2.  The div tag equipped with CSS rules produces good looking pages.  With CSS, the div tag can easily be positioned anywhere on the page.
Objectives Create a reset style sheet Explore page layout designs
Styles and the Box Model
Controlling Layout with Style Sheets
Second CSS Lecture Applications to XML
Positioning.
MORE Cascading Style Sheets (The Positioning Model)
Using HTML Tables SWBAT: - create tables using HTML
HTML – Organizing Page Content
HTML – Organizing Page Content
Web Development & Design Foundations with H T M L 5
More CSS Page layout Boriana Koleva Room: C54
More CSS 22-Feb-19.
Positioning.
Positioning.
Laying out Elements with CSS
CSS Applications to XML 20-May-19.
CSc 337 Lecture 5: Grid layout.
CSS Applications to XML 3-Jul-19.
Positioning Boxes Using CSS
CGS 3066: Web Programming and Design Fall 2019 CSS Part 2
Presentation transcript:

Floating and Positioning Chapter 15 Floating and Positioning

Normal Flow Text elements are laid out from top to bottom in the order in which they appear in the source, and then from left to right. Block elements stack up on top of one another and fill the available width of the browser window or other containing element. Inline elements and text characters line up to one another to fill block elements.

Normal Flow Behavior

Float vs. position Floating an element moves it to the left or right, allowing the following text to wrap around it. Positioning is a way to specify the location of an element anywhere on the page. Normal flow is top to bottom, left to right

float Primary tool in modern CSS-based web design Used to create multicolumn layouts Navigation toolbars from lists Table-like alignment without tables

Float Moves element as far as possible to right or left allowing following content to wrap around it. Edit floatStart.html to change position of image

What code would generate the following effect? img { float: right; margin: 10px; } img { float: left; margin: 10px; } None of the above A

Things to remember about float A floated element is like an island in a stream – the stream has to flow around it Floats stay in the content area of the containing element Margins are maintained Move the image outside of the p tags and take out style… show boxes… draw boxes for when it is in the p tag

Floating non-images Always provide a width for floated elements Floated inline elements behave as block elements Margins on floated elements do not collapse demo this

Always provide a width for floated text elements Normal flow, abutting top and bottom margins collapse (overlap), but for floated elements, the margins are maintained on all sides as specified.

How do you turn Floating off?? Turn off to get back to layout as usual Use the attribute clear: p { clear: left; } show paddingMargins.html, margins.html

using floats to create columns For 2-column layout, you can do: Float one div and add a wide margin on the side of the text element that wraps around it Float both divs to the left or right Float one div to the left and the second div to the right Need to be sure that every float has a specified width Total width of all columns (don’t forget padding, borders and margins) cannot exceed the width of the browser Add main and side content to file and show the different widths Show adding columns… show difference between floating left and floating right with placement of sections

positioning Two types: relative absolute moves the box relative to original position space the element would have occupied in the normal flow is preserved as an empty space absolute elements are removed from normal flow positioned with respect to the browser window or a containing element

How to specify position Provide values for each of the offset properties representing the distance the element should be moved away from that respective edge. top left bottom right

Relative positioning

Absolute positioning Absolute positioning is that the element is positioned relative to its nearest containing block show positioning.html

Which of the following is not true of floated elements? All floated elements behave as block elements. Floats are positioned against the padding edge of the containing element. The contents of inline elements flow around a float, but the element box is unchanged. You must provide a width property for floated block elements. B is not true. Floats are positioned against the content edge, not the padding edge.

B is not true Floats are positioned against the content edge, not the padding edge.

Which of these style rules is incorrect? img { float: left; margin: 20px; } float: right; width: 120px; height: 80px; img { float: right; right: 30px; } float: left; margin-bottom: 2em; c is incorrect. Floats do not use offset properties, so there is no reason to include right.

C is incorrect Floats do not use offset properties, so there is no reason to include right.

Demo