IS1825 Developing Multimedia Applications for Business Lecture 4: CSS Positioning and Flow Rob Gleasure

Slides:



Advertisements
Similar presentations
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.
Advertisements

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.
Cascading Style Sheets Color and Background Controls Border and Margin Controls (Boxes)
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.
WEB DESIGN Multimedia and Web. Today’s Objectives  Quick review selector types  Layout and positioning.
CS4370/6370 Web Development Cascading Style Sheets (CSS)
Web Design & Development Cascading Style Sheets (CSS)
TUTORIAL 4: CREATING PAGE LAYOUT WITH CSS Session 4.3.
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.
CS428 Web Engineering Lecture 06 Introduction (Cascading Style Sheet) 1.
CSS II Digital Media: Communication and design IT University of Copenhagen.
MORE Cascading Style Sheets (The Positioning Model)
1 The Box Model. 2 XHTML Elements Block and inline elements Block is a stand alone element and inline goes inside block elements CSS allows you to control.
4.01 Cascading Style Sheets
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.
IMAGES Controlling size of images in CSS Aligning images in CSS Adding background images.
CSS Dvijesh Bhatt.
WRT235: Writing in Electronic Environments CSS Backgrounds, colors, fonts.
Doman’s Sections Information in this presentation includes text and images from
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.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Cascading Style Sheet Bayu Priyambadha, S.Kom. Definition Cascading Style Sheets (CSS) form the presentation layer of the user interface. –Structure (HTML)
11/6/13 MORE CSS!. TODAY’S AGENDA Review: float for positioning objects Review: CSS and color Introductions to: o CSS and images o CSS backgrounds o CSS.
Tutorial #6 – Creating Fixed Width Layouts. Tutorial #5 Review – Box Model Every html element is surround by a box Content, Padding, Border, Margin Can.
Lesson 03 // Cascading Style Sheets. CSS Stands for Cascading Style Sheets. We’ll be using a combination of Html and CSS to create websites. CSS is a.
More CSS.
Web Design and Development for Business Lecture 4 Cascading Style Sheet (CSS)
Chcslonline.org Text –wrapping around Images. chcslonline.org To wrap text around an image, lets set up a style in our style sheet. open a new notepad.
INTRODUCTORY Tutorial 4 Exploring Graphic Elements and Images.
CSE 154 LECTURE 4: FLOATING AND POSITIONING. The CSS float property propertydescription floatside to hover on; can be left, right, or none (default) a.
More css HTML and css 2012 Brian Davison. DIV Use... to mark a division or section of your Web page Lorem ipsum dolor sit amet, consectetur adipiscing.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
Colors and backgrounds The following CSS properties will be explained: 1.color 2.background-color 3.background-image 4.background-repeat 5.background-attachment.
DIV, Span, CSS.
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 11: Deeper into CSS - Spring 2011.
THE BOX MODEL Putting layouts together with CSS. The Box Model  How would you describe a box?  Container?  Tags or elements are “containers”  puts.
REEM ALMOTIRI Information Technology Department Majmaah University.
Colors and backgrounds The following CSS properties will be explained: 1.color 2.background-color 3.background-image 4.background-repeat 5.background-position.
3.2 Cascading Style Sheets. 2 Positioning Elements Normally, elements are laid out on the page in the order that they are defined in the XHTML document.
Web Design (12) CSS Introduction. Cascading Style Sheets - Defined CSS is the W3C standard for defining the presentation of documents written in HTML.
Web Technologies Beginning Cascading Style Sheets (CSS) 1Copyright © Texas Education Agency, All rights reserved.
CONTROLLING Page layout
5 th ed: Chapter 4 4 th ed: Chapter 5 SY306 Web and Databases for Cyber Operations SlideSet #5: Advanced CSS.
CSS - Quiz #3 Lecture Code:
CSS: Cascading Style Sheets Part II. Style Syntax.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. September 22, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and.
Web Design (15) CSS Opacity, Link Colours & Background Images.
CIS234A Lecture 6 Instructor Greg D’Andrea. Span and Div The span and div elements are a generic means by which we can add structure to documents. The.
Cascading Style Sheet (CSS) SAMPLE IT133 Pengembangan Web.
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.
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.
Tutorial #5 Working with the Box Model. Tutorial #4 Review - CSS Create a homework page Final Project Discussion Exam on Blackboard Styling Lists (List-style-type,
PERSPECTIVES: TUTORIAL 4 CREATING PAGE LAYOUTS WITH CSS.
Agenda Cascading Style Sheets Selectors and Declarations Fonts and Font Families Content Flow Positioning Content Overflow.
CS 120: Introduction to Web Programming Lecture 10: Extra Features and Website Design Part 1 Tarik Booker CS 120 California State University, Los Angeles.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
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,
CSS Layouts: Grouping Elements
Webpage layout using CSS
CS1220 Web Programming Saloni Chacha.
Lecture 5: Floating and Positioning
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Web Programming Language
SEEM4570 Tutorial 3: CSS + CSS3.0
CSc 337 Lecture 4: Positioning.
Laying out Elements with CSS
CSc 337 Lecture 5: Grid layout.
Positioning Boxes Using CSS
Presentation transcript:

IS1825 Developing Multimedia Applications for Business Lecture 4: CSS Positioning and Flow Rob Gleasure

IS1825 Today’s lecture  CSS flow  CSS positioning  CSS backgrounds  CSS layers

The doctype declaration Generally when we are creating HTML pages, we will start with a tag that lets a browser know the version of HTML that we are running We haven't worried about this until now, but we need to add this in to help our CSS render consistently across browsers We are using HTML 4.01 transitional, which can be represented by the following tage

A starting point for your HTML files For all of your HTML pages, you can start with the following basic template This line lets a browser know the version of HTML that we are running (HTML 4.01 transitional) This line specifies the character set used for the page

CSS Flow We noted previously that and behave differently in one key way  Placing an item in a caused the item to be placed on a new line  It did this because has a flow type of ‘block’, whereas has a flow type of ‘inline’ We’ve come across this before, e.g. and are displayed by default according to a ‘block’ flow, and are displayed by default according to an ‘inline’ flow

CSS Block Flow Block Flow Block elements by default are as wide as the container surrounding them and fall on a new line  Try out this code: div {height: 200px; border-style: solid; padding:10px; } div#container { width: 550px; height:700px; } div.small { width: 250px; background-color: red;} div#big { background-color: green;}

CSS Inline Flow Inline Flow Inline elements stack left until a new line is necessary to fit content. They also technically ignore width specifications*  Try out this code: div {height: 200px; border-style: solid; padding:10px; } div#container { width: 550px; height:700px; } div.small { width: 250px; background-color: red; display: inline;} div#big { background-color: green; display: inline;}

CSS Floats Items can also be set to rest to the leftmost or rightmost available position using the float property,  Try out this code: img#left { float:left; } img#right { float:right; } div#container { border-style:solid; width: 600px; height:400px; } Look what happens to the positioning of the images Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer at rhoncus magna. Sed leo nunc, viverra eget tincidunt ut, venenatis in nibh Vivamus leo nunc, malesuada fermentum consequat id, sagittis vel urna. Mauris nunc justo, convallis lacinia lacinia nec, tincidunt pellentesque felis.

Three Kinds of Positioning Fixed positioning, i.e. Element is positioned relative to the browser window and will not move even if the window is scrolled, e.g. #fixedEg { position: fixed; top: 100px; left: 100px; } Absolute positioning, i.e. Element is positioned relative to the first parent element that has a position other than static. If no such element is found, the containing block is, e.g. #absEg { position: absolute; top: 100px; left: 100px; } Relative positioning, i.e. Element is positioned relative to its normal default position, e.g. #relEg { position: relative; top: 100px; left: 100px; }

Relative Positioning of Divs Look at what happens when we try out the following code Relative positioning <!-- #first { border:2px solid rgb(00,250,00); position: relative; top: 0px; left: 0px; width: 800px; height: 800px; padding:0px; margin:0px; } #second { border:2px solid rgb(250,00,00); position: relative; top: 200px; left: 200px; width: 400px; height: 400px; padding:0px; margin:0px; }

Relative Positioning of Divs (cont) #third { border:2px solid rgb(00,00,250); position: relative; top: 100px; left: 100px; width: 200px; height: 200px; padding:0px; margin:0px; } -->

Absolute Positioning of Divs Look at what happens when we try out the following code Absolute positioning <!-- #first { border:2px solid rgb(00,250,00); position: absolute; top: 0px; left: 0px; width: 800px; height: 800px; padding:0px; margin:0px; } #second { border:2px solid rgb(250,00,00); position: absolute; top: 200px; left: 200px; width: 400px; height: 400px; padding:0px; margin:0px; }

Absolute Positioning of Divs (cont) #third { border:2px solid rgb(00,00,250); position: absolute; top: 300px; left: 300px; width: 200px; height: 200px; padding:0px; margin:0px; } -->

Fixed Positioning of Divs Look at what happens when we try out the following code Fixed positioning <!-- #first { border:2px solid rgb(00,250,00); position: absolute; top: 0px; left: 0px; width: 800px; height: 800px; padding:0px; margin:0px; } #second { border:2px solid rgb(250,00,00); position: fixed; top: 200px; left: 200px; width: 400px; height: 400px; padding:0px; margin:0px; }

Fixed Positioning of Divs (cont) #third { border:2px solid rgb(00,00,250); position: absolute; top: 300px; left: 300px; width: 200px; height: 200px; padding:0px; margin:0px; } -->

CSS Backgrounds and Images Background Images  We have seen already that CSS allows images to be used as a background for images, e.g. body { background-image: url(‘bg.gif’);}  We can also choose whether we would like the backgroudn image to be fixed or to scroll with the page using the background- attachment property, e.g. background-attachment: fixed; or background-attachment: scroll;

Background Property Tiled backgrounds  We can also specify whether the image repeats on the screen, as well as how it repeats p{ background-repeat: repeat-x; } /* Tile Horizontally */ p{ background-repeat: repeat-y; } /* Tile Vertically */ p{ background-repeat: repeat; } /* Tile Vert. & Horiz. */ p{ background-repeat: no-repeat; } /*Do not tile*/ Note: resizing background images is awkward with CSS and is best done with Photoshop, GIMP, etc

Background Property Try out the following code div#container { background-image: url(' width: 550px; height:700px; border-style: solid; } div.small { width: 250px; }

Background Property You should see the following: Insert the following line of code and you should see: div#container { background-image: url(' width: 550px; height:700px; border-style: solid; background-repeat: repeat-y; }

Background Property To place the image only once, change this to: div#container { background-image: url(' width: 550px; height:700px; border-style: solid; background-repeat: no-repeat; }

Background Property We can also stop an image from scrolling using the background- attachment: value of fixed: div#container { background-image: url(' width: 550px; height:900px; border-style: solid; } body { background-image:url(' tbn1.gstatic.com/images?q=tbn:ANd9GcSzg142QHHn3NvFWHK6w0y4EsjMHtKhkhTJO31VPNaO-3LP7SniAg'); background-repeat:no-repeat; background-attachment:fixed; background-position:center; }

CSS and Layering As we discussed when we were covering the CSS ‘box model’, HTML elements are layered on top of one another automatically, each item nested inside others  We can over-ride this for our layout using CSS To manually define a priority, we set a z-index value.  The larger the value of an element, the higher the priority h1{ z-index: 2;} p {z-index: 1;} Here, the heading would be placed on top of the paragraph

CSS and Layering (cont) Copy the following code into a new webpage and save it as layers.html #first {background-color:rgb(00,150,200); z-index: 0; position: fixed; top: 100px; left: 100px; width: 400px; height: 400px;} #second { background-color:rgb(00,200,100); z-index: 1; position: relative; top: -50px; left: 250px; width: 200px; height: 200px;} #third {background-color:rgb(200,00,50); z-index: 2; position: absolute; top: 100px; left: 100px; width: 200px; height: 200px; } #fourth {background-color:rgb(200,00,250); z-index: 3; position: absolute; top: 250px; left: -50px; width: 200px; height: 200px; } #fifth {background-color:rgb(250,200,00); z-index: 4; position: absolute; top: 275px; left: 75px; width: 200px; height: 200px; } first second third fourth < div id="fifth">fifth

Note on Centralising Content in CSS We centre things in CSS using a very simple line of code, i.e. margin: 0 auto  Note that for this to work in IE we need to include the doctype <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " div {height: 200px; border-style: solid; padding:10px; } div#container { width: 550px; height:700px; } div.small { width: 250px; background-color: red; margin: 0 auto}

Exercise Save this basic template as lecture13.html div { border-style:solid; border-width: 2px;} div#left_nav { padding-left:10px; background-color: #99CC00; } Lorem Lorem ipsum

Exercise (continued) In the internal CSS  For the body element Set the background-image to url(‘ Set the background-position to right Set the background-repeat to repeat-y  Create the banner ID, then set the width to 1000px and the height to 250px  Create the main_content ID, then set the width to 750px and the height to 800px  Create the footer ID, then set the width to 850px and the height to 100px

Exercise (continued)  Centre-align the banner, main_content and footer IDs by setting the margin property to 0 auto  For left_nav Set the width to 750px and the height to 800px Set position to be fixed, then set top to 250px and left to 275px Use the z-index to bring this div to the front  Set the a:hover to increase font-size to 200%

Exercise You should end up with a page that looks like this

Want to read more? and-positioning-for-web-pages.php and-positioning-for-web-pages.php Layout-with-CSS/2/ Layout-with-CSS/2/ positioning/ positioning/ positioning/ positioning/