269200 Web Programming Language CSS – Part 2 Dr. Ken Cosh (CSS II)

Slides:



Advertisements
Similar presentations
Introduction to HTML & CSS
Advertisements

Week 10 Creating Positioned Layouts
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.
CGS 3175: Internet Applications (CSS – Page Layout) Page 1 © Mark Llewellyn CGS 3175: Internet Applications Fall 2008 Cascading Style Sheets – Page Layout.
CSS provides a way to stray away from the traditional methods of using tables to lay out pages. Success with this technique depends on understanding of.
Tutorial 6 Creating Fixed-Width Layouts
Web Design HTML Basic Robertus Setiawan Aji Nugroho References: w3schools.com.
WEB DESIGN Multimedia and Web. Today’s Objectives  Quick review selector types  Layout and positioning.
16 HTML Tables and Frames Section 16.1 Create a basic table using HTML Define borders Merge cells Align content in tables Section 16.2 Create a frames-based.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
MORE Cascading Style Sheets (The Positioning Model)
ADVANCED CSS: (LAYERED) DISPLAY & PRESENTATION PA 70b – Giordon Stark.
CSS (Cascading Style Sheets): How the web is styled Create Rules that specify how the content of an HTML Element should appear. CSS controls how your web.
Web Development & Design Foundations with XHTML Chapter 6 Key Concepts.
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.
Multimedia & The World Wide Web winny HCI 201 Multimedia and the www.
Basic Responsive Design Techniques. Let’s take a look at this basic layout. It has a header and two columns of text, in a box that is centered on the.
Cascading Style Sheets. Defines the presentation of one or more web pages Similar to a template Can control the appearance of an entire web site giving.
MCS 270 Cascading Style Sheets (CSS) Gustavus Adolphus College.
Web Programming Language Dr. Ken Cosh Week 2 (CSS I)
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.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
 Website development process  CSS  Javascript.
Introduction to Programming the WWW I CMSC Winter 2003 Lecture 7.
CSS = Cascading Style Sheet CSS consists of rules to display, style and decorate HTML elements Why CSS ? – Separate decoration from HTML markup (Ex :,,…)
CSCE 102 – Chapter 6 (Web Design and Layout) CSCE General Applications Programming Benito Mendoza Benito Mendoza 1 By Benito Mendoza.
Web sites Design: Cascading Style Sheet (CSS) (Cont’d) Dimensions and Position of Elements –Width and Height Space –Table Cell Padding –Left and Top Position.
Creating a Dynamic Web Page Template Module 5: Beyond the Basics with Expression Web LESSON 10.
THE BOX MODEL Putting layouts together with CSS. The Box Model  How would you describe a box?  Container?  Tags or elements are “containers”  puts.
INTRODUCTORY Tutorial 5 Using CSS for Layout and Printing.
11/12/2015 Box Model Reed Crouch. 11/12/2015  HTML elements can be considered as boxes. In CSS, the term "box model" is used when referring to layout.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
Cascading Style Sheets (CSS) Part II IT210: Web-based IT.
CSS Positioning & Layout Creating layouts and controlling elements.
CONTROLLING Page layout
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.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. September 22, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and.
- 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.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. August 25, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and CIS.
NASRULLAHIBA.  It is time to take your web designing skills to the next level with Cascading Style Sheets (CSS). They are a way to control the look 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.
INTERNET APPLICATIONS CPIT405 CSS Cascading Style Sheet Instructor: Omnia H. Alwazzan
Cascading Styles Sheets Positioning HTML elements.
Cascading Style Sheets for layout
CSS.
Laying out Elements with CSS
More HTML and CSS Basic Layout with Styles
4.01 Cascading Style Sheets
Advanced CSS BIS1523 – Lecture 20.
Nesting and Floating Elements
Cascading Style Sheets for layout
Cascading Style Sheets (Layout)
Putting Things Where We Want Them
Creating Layouts Using CSS
Styles and the Box Model
Controlling Layout with Style Sheets
Second CSS Lecture Applications to XML
Positioning.
MORE Cascading Style Sheets (The Positioning Model)
Web Programming Language
Web Programming Language
Web Programming Language
Positioning.
Laying out Elements with CSS
4.01 Cascading Style Sheets
The div Element and CSS for layout
CSc 337 Lecture 5: Grid layout.
Presentation transcript:

Web Programming Language CSS – Part 2 Dr. Ken Cosh (CSS II)

Review Last time we learnt about CSS. Defining Selectors HTML Selectors Class Selectors ID Selectors The power of and Site styles The focus was on using CSS for Style…

This week CSS can also be used to help with layout, and this week we will investigate this. We touched on it briefly last time on slide 18

Slide 18 revisited… The general syntax for an ID selector is: #IDSelector {Property:Value;} For example: #layer1 {position:absolute; left:100;top:100; z-Index:0} #layer2 {position:absolute; left:140;top:140; z-Index:1} THIS IS LAYER 1 POSITIONED AT 100,100 THIS IS LAYER 2 POSITIONED AT 140,140

What did that do? Well, it created 2 ‘layers’. But, lets take a closer look… I think ‘top’ and ‘left’ should be clear enough, but what about the other parameters? The key is “position:_____”

position: static; Default = ‘static’ This doesn’t really mean a lot, except that the element is not positioned, and appears where it normally would in the document!

THE CODE:.position-static { position:static; } Here is some staticly positioned text - exciting isn't it???

position: absolute; absolute allows you to remove elements from the page, and position them precisely. #top-corner { position:absolute; top:0; right:0; width:200px; } This would create a box that appears in the top right corner of the page, irrespective of any other elements around it.

THE CODE.position-absolute { position:absolute; top:0; right:0; width:200px; } This is text absolutely positioned in the top right corner of the page - awesome stuff! :)

position: relative Relative positioning places an element on the page relative to where it should be… #down-left { position:relative; top:20px; left:-40px; } This would move the element down (20 pixels) and to the left (40 pixels). Note that while the element moves on the page, it remains where it is in the document.

THE CODE.position-relative { position:relative; top:40px; left:-40px; } This text is positioned a little down and to the left of where it should be (relative to the page)

Combining Relative & Absolute We can also place an absolutely positioned element within a relatively positioned element. Some Element In this case the relative element is relative to the document, while the absolute element is positioned precisely within the relative element.

THE CODE.position-relative2 { position:relative; width:400px; }.position-absolute { position:absolute; top:0; right:0; width:200px; } This text is positioned absolutely within a relatively positioned element. The relative element is 400 pixels wide, while the absolute element is in the top right of that box.

Tables in CSS! Remember in HTML we had troubles positioning elements on the page, and resorted to using tables? Well, its much easier in CSS to precisely position elements on the page, and it is a small step forward to create a table like structure using CSS. Some Element Other Element

THE CODE.position-relative2 { position:relative; width:400px;}.position-absolute { position:absolute; top:0; right:0; width:200px;}.position-absolute2 { position:absolute; top:0; left:0; width:200px;} This text is positioned absolutely within a relatively positioned element. The relative element is 400 pixels wide, while the absolute element is in the top right of that box. This text is also positioned absolutely within the relatively positioned element. Even though this text appears to the left, in the HTML document it occurs after the text to the right! Thats because they are both absolutely placed!

The absolute problem The problem with the absolute elements is that as they are removed from the page. This means they will appear over any subsequent elements. We could use the height property to specify how large the element will be.

THE CODE.position-relative3 { position:relative; width:400px; height:200px;}.position-absolute { position:absolute; top:0; right:0; width:200px;}.position-absolute2 { position:absolute; top:0; left:0; width:200px;} This text is positioned absolutely within a relatively positioned element. The relative element is 400 pixels wide, while the absolute element is in the top right of that box. This text is also positioned absolutely within the relatively positioned element. Even though this text appears to the left, in the HTML document it occurs after the text to the right! That’s because they are both absolutely placed!

Problem with height We could use the height property to specify how large the element will be. But often we don’t know the height Different font sizes Different amounts of text

Float The Float property can be used to float elements to a particular position. This is often used as a way to wrap text around an image. float:left;

THE CODE.position-relative3 { position:relative; width:400px; height:200px;}.position-float { float:left; width:200px;} The element to the left is a picture of some great legs! It is floated to the left of the element, which means this text will wrap around the bottom of the picture, assuming there is enough text that is, which is why I am writing such a long boring paragraph of content here! How much text can I write before it will finally wrap around the bottom? Clearly this isn't going to work for a 'table' with different sized columns.

Float for Tables We can float more than one column in a table to the left, so they neatly appear next to each other, without needing to worry about the heights of each column. The problem comes after the floats finish – where exactly in the document should the browser continue from?

THE CODE.position-relative3 { position:relative; width:400px; height:200px;}.position-float2 { float:left; width:150px;} The element to the left is a picture of some great legs! It is floated to the left of the element, which means this text will wrap around the bottom of the picture, assuming there is enough text that is, which is why I am writing such a long boring paragraph of content here! How much text can I write before it will finally wrap around the bottom? Clearly this isn't going to work for a 'table' with different sized columns.

clear:both A powerful CSS tag is “clear:both”, have a look what happens after we call it…

THE CODE.position-relative3 { position:relative; width:400px; height:200px;}.position-float { float:left; width:200px;}.clear { clear:both;} The element to the left is a picture of some great legs! It is floated to the left of the element, which means this text will wrap around the bottom of the picture, assuming there is enough text that is, which is why I am writing such a long boring paragraph of content here! How much text can I write before it will finally wrap around the bottom? Clearly this isn't going to work for a 'table' with different sized columns. Just use a "clear:both" class to solve that problem!

CSS for Layout I normally have 2 stylesheets for a website – one for style and one for layout. Design the site on paper. Identify classes and id’s. Reuse ‘useful’ styles…

Assignment Check Out the Design of Ken’s Baby Store. It is your job to create a page (using HTML, CSS) that looks just like it!