Cascading Style Sheets for layout II CS7026

Similar documents
Styles, Style Sheets, the Box Model and Liquid Layout

Using CSS for page layout

Create a three column layout using CSS, divs and floating

HTML Organizing Page Content

Using Dreamweaver CC. Logo. 4 Creating a Template. Page Heading. Page content in this area. About Us Gallery Ordering Contact Us Links

HTML and CSS a further introduction

When you complete this chapter, you will be able to:

CSS worksheet. JMC 105 Drake University

Using Dreamweaver CS6

COMSC-031 Web Site Development- Part 2

Chapter 16: PAGE LAYOUT WITH CSS

Page Layout. 4.1 Styling Page Sections 4.2 Introduction to Layout 4.3 Floating Elements 4.4 Sizing and Positioning

CSS Layout Part I. Web Development

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) More on Relative Linking. Learning Objectives (2 of 2)

ORB Education Quality Teaching Resources

CS193X: Web Programming Fundamentals

HTML5: Adding Style. Styling Differences. HTML5: Adding Style Nancy Gill

What is the Box Model?

TAG STYLE SELECTORS. div Think of this as a box that contains things, such as text or images. It can also just be a

IMY 110 Theme 7 HTML Tables

Cascading Style Sheets Level 2

Introduction to HTML & CSS. Instructor: Beck Johnson Week 2

Creating and Building Websites

CS7026 Media Queries II. Different Screen Size Different Design

COMP519 Web Programming Lecture 8: Cascading Style Sheets: Part 4 Handouts

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

Table Basics. The structure of an table

HTML Organizing Page Content

CSS for Page Layout Robert K. Moniot 1

Block & Inline Elements

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

Header. Article. Footer

Lesson 1 using Dreamweaver CS3. To get started on your web page select the link below and copy (Save Picture As) the images to your image folder.

CREATING A WEBSITE USING CSS. Mrs. Procopio CTEC6 MYP1

What do we mean by layouts?

Web Site Design. Stanford University Continuing Studies CS 03. Mark Branom

CSS: Layout, Floats, and More

How to deploy for multiple screens

Assignments (4) Assessment as per Schedule (2)

COMS 359: Interactive Media

CSS Mapping in Advanced Mode for Events. Cvent, Inc 1765 Greensboro Station Place McLean, VA

INTRODUCTION TO HTML5! CSS Styles!

Introduction to Cascading Style Sheet (CSS)

How to lay out a web page with CSS

PIC 40A. Lecture 4b: New elements in HTML5. Copyright 2011 Jukka Virtanen UCLA 1 04/09/14

Web Design and Implementation

Getting Started with CSS Sculptor 3

ADOBE 9A Adobe Dreamweaver CS4 ACE.

Getting Started with Zurb Foundation 4

The Importance of the CSS Box Model

Guidelines for doing the short exercises

Chapter 7 BMIS335 Web Design & Development

Layout with Layers and CSS

Building Page Layouts

Designing the Home Page and Creating Additional Pages

Dreamweaver CS5 Lab 4: Sprys

Zen Garden. CSS Zen Garden

Graduating to Grid. An Event Apart Orlando

VISA/APCO/STAC 2P61 WEBSITE CREATION Fall Term 2012

HIERARCHICAL ORGANIZATION

Programmazione Web a.a. 2017/2018 HTML5

Tai-Jin Lee. Handout #5 11/01/2005. Navigation

[PACKT] HTML5, CSS3, and jquery. Dreamweaver CS5.5 Mobile. and Web Development with

Responsive Web Design (RWD)

Create a Web Page with Spry Navigation Bar. March 30, 2010

Taking Fireworks Template and Applying it to Dreamweaver

Introduction to Computer Science Web Development

Chapter 3 Style Sheets: CSS

Building Responsive Layouts

GIMP WEB 2.0 MENUS WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR CREATING AN HTML LIST

To place an element at a specific position on a page use:

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

Siteforce Pilot: Best Practices

Getting Started with Eric Meyer's CSS Sculptor 1.0

BA. (Hons) Graphics Design

WEBSITE PROJECT 2 PURPOSE: INSTRUCTIONS: REQUIREMENTS:

WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5

Default Page Dimensions in pixels

2005 WebGUI Users Conference

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar with Dynamic Background Image

CHRIS SAUVE 2

Magazine-style websites often have lots of small items on a page. First you re going to create a heading and background for your magazine.

CS Multimedia and Communications. Lab 06: Webpage Tables and Image Links (Website Design part 3 of 3)

Hyper- Any time any where go to any web pages. Text- Simple Text. Markup- What will you do

The default style for an unordered (bulleted) list is the bullet, or dot. You can change the style to either a square or a circle as follows:

Web Site Design and Development Lecture 9. CS 0134 Fall 2018 Tues and Thurs 1:00 2:15PM

Fixed-width. Liquid. Web Development 1 CS1115/CS5002. Types of layout. relative, fixed), CSS Flexbox layout or CSS Grid Layout

IDM 222. Web Design II. IDM 222: Web Authoring II 1

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

Review of HTML. Chapter Pearson. Fundamentals of Web Development. Randy Connolly and Ricardo Hoar

Adobe Fireworks CS Essential Techniques

Chapter 1 Introduction to Dreamweaver CS3 1. About Dreamweaver CS3 Interface...4. Creating New Webpages...10

EXPLORE MODERN RESPONSIVE WEB DESIGN TECHNIQUES

CSS: Layout Part 2. clear. CSS for layout and formatting: clear

Tutorial 4. Activities. Code o Editor: Expression Web o Focus : Base Layout, navigation with folders, external stylesheets, Open up Expression Web

Positioning in CSS: There are 5 different ways we can set our position:

ABOUT CSS Class Styles... 13

CSS THE M\SS1NG MANUAL. David Sawyer McFarland. POGUE PRESS" O'REILLr Beijing Cambridge Farnham Köln Paris Sebastopol Taipei Tokyo

Transcription:

Cascading Style Sheets for layout II CS7026

Understanding CSS float The CSS float property is also a very important property for layout. It allows you to position your Web page designs exactly as you want them to display. A CSS float property looks like this:.right {float: right;} 2

What Floats? You can't float every element on a Web page. To get technical, you can only float block-level elements. Reminder: A block-level element always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can). Examples of block-level elements: <div>, <h1> - <h6>, <p>, <form> An inline element does not start on a new line and only takes up as much width as necessary. Examples of inline elements: <span>, <a>, 3

Where Do They Float? You can float elements to the right or the left. Any element that follows the floated element will flow around the floated element on the other side. E.g, An image that is placed in a block of text without any float style applied to it will display as the browser is set to display images. This is usually with the first line of following text displayed at the bottom of the image. If I float an image to the left, any text or other elements following it will flow around it to the right. If I float an image to the right, any text or other elements following it will flow around it to the left. 4

How Far Will They Float? An element that has been floated will move as far to the left or right of the container element as it can. This results in several different situations depending upon how your code is written. Lets look at floating a small <div> to the left: 5

How Far Will They Float? If the floated element does not have a pre-defined width, it will take up as much horizontal space as required and available, regardless of the float. If the container element is the HTML body, the floated div will sit on the left margin of the page. If the container element is itself contained by something else, the floated div will sit on the left margin of the container. 6

How Far Will They Float? Floated elements will sit next to each other if there is room in the container. For example, this container has 3 100px wide divs floated in a 400px wide container. 7

Turning Off the Float You turn off the float with the CSS clear property. You can clear left floats, right floats or both: clear: left; clear: right; clear: both; Any element that you set the clear property for will appear below an element that is floated that direction. 8

Using Floats for Layout Once you understand how the float property works, you can start using it to lay out your Web pages. Design the layout (on paper or in a graphics tool). Determine where the site divisions are going to be. Determine the widths of the various containers and the elements within them. Float everything. As long as you know the widths (percentages are fine) of your layout sections, you can use the float property to put them where they belong on the page. 9

What are Floats used for? Aside from the simple example of wrapping text around images, floats can be used to create entire web layouts. 10

Clearing the Float for Layout An element that has the clear property set on it will not move up adjacent to the float like the float desires, but will move itself down past the float. Here, the sidebar is floated to the right and is shorter than the main content area. The footer then is required to jump up into that available space as is required by the float. 11

Clearing the Float for Layout To fix this problem, the footer can be cleared to ensure it stays beneath both floated columns. #footer { clear: both; } 12

Float for Layout 1. Set a width on your page by creating a container You don't have to do this, but most pages are easier to read if you don't assume that everyone will have their browser set to the same settings as your browser. A lot of people design for 1024x768 resolution, with a typical width of around 960px. However, you can also do fluid widths using percentages. } #container { width: 960px; background: #FFF; margin: 0 auto; /* the auto value on the sides, coupled with the width, centres the layout */ 13

Float for Layout 2. Float everything Once you have your maximum width, then you can float everything on the page, and have it line up. E.g. if you want your navigation <div> to be at the top of the page, you would make it have a width of 100% and float left. #nav { width: 100%; float: left; } But if you wanted it to be on the right side, you'd make it a width of less than 100% and float right. #nav { width: 200px; float: right; } Then, anything that comes after it would be floated left, and as long as those elements had a smaller width than 600px (800-200), they would slide right in to the left of the navigation. 14

Float for Layout 3. Use floats to create margins One of the great things about floats is that you can use them to create margins without using CSS. E.g., if my navigation is on the right and 240px wide and my content area is floated left and 700px wide, there will be a 20px margin between the two elements, without any margin tags at all. #nav { width: 240px; float: right; } #content { width: 700px; float: left; } 15

Float for Layout 4. Get multiple columns by nesting <div> elements If you want three columns, you create two divs that float left and right, and then in the wider div, you create a second set of two columns that float left and right inside it. HTML: <div id="leftside"> <div id="leftcolumn">left column </div> <div id="centrecolumn">centre column </div> </div> <div id="rightside">right column </div> 16

Float for Layout CSS (note that the inner divs have a width of 50% because they are half of the outer container, which is the "leftside" div: #leftside { width: 66%; float: left; } #rightside { width: 33%; float: right; } #leftcolumn { width: 50%; float: left; } #centercolumn { width: 50%; float: right; } 17

Float for Layout 5. Test in multiple browsers While this technique works most of the time, some browsers react strangely to floats. You may have to play with the widths to get your elements to show up correctly. 18