Web Programming Step by Step

Similar documents
The CSS Box Model. Motivation. CSS Box Model. CSE 190 M (Web Programming), Spring 2008 University of Washington

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

EECS1012. Net-centric Introduction to Computing. Lecture 5: Yet more CSS (Float and Positioning)

CSE 154 LECTURE 5: FLOATING AND POSITIONING

FLOATING AND POSITIONING

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

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

CSS Selectors. element selectors. .class selectors. #id selectors

ITNP43: HTML Lecture 5

Building Page Layouts

CSS for Page Layout Robert K. Moniot 1

ADOBE 9A Adobe Dreamweaver CS4 ACE.

Client-Side Web Technologies. CSS Part II

Internet Programming 1 ITG 212 / A

Chapter 4 Page Layout

The Importance of the CSS Box Model


CSS3 Basics. From & CSS Visual Dictionary Learning Curve Books, LLC

Using CSS for page layout

CSS: Layout, Floats, and More

Parashar Technologies HTML Lecture Notes-4

Cascading Style Sheet Quick Reference

Web Design and Implementation

Assignments (4) Assessment as per Schedule (2)

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

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

<body bgcolor=" " fgcolor=" " link=" " vlink=" " alink=" "> These body attributes have now been deprecated, and should not be used in XHTML.

Wanted! Introduction. Step 1: Styling your poster. Activity Checklist. In this project, you ll learn how to make your own poster.

COMM 2555: Interactive Digital Communication / Spring 2018 Lab 9: Basic layout techniques with CSS

IDM 221. Web Design I. IDM 221: Web Authoring I 1

Styles, Style Sheets, the Box Model and Liquid Layout

What do we mean by layouts?

COMS 359: Interactive Media

CSC309 Winter Lecture 2. Larry Zhang

Appendix D CSS Properties and Values

CSCU9B2: Web Tech Lecture 3

COSC 2206 Internet Tools. CSS Cascading Style Sheets

Cascading Style Sheets (CSS)

Adding CSS to your HTML

Web Engineering CSS. By Assistant Prof Malik M Ali

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

CSS Box Model. Cascading Style Sheets

CSS: Lists, Tables and the Box Model

Web Design and Development ACS Chapter 12. Using Tables 11/23/2017 1

IMY 110 Theme 7 HTML Tables

c122sep2214.notebook September 22, 2014

COMSC-031 Web Site Development- Part 2

12/9/2012. CSS Layout

<style type="text/css"> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page***

Fundamentals of Web Technologies. Agenda: CSS Layout (Box Model) CSS Layout: Box Model. All HTML elements can be considered as a box or a container

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

What is the Box Model?

Table of Contents. MySource Matrix Content Types Manual

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

HTML Organizing Page Content

CS193X: Web Programming Fundamentals

BIM222 Internet Programming

Creating Layouts Using CSS. Lesson 9

subject to an additional IP rights grant found at polymer.github.io/patents.txt -->

2005 WebGUI Users Conference

CSS. Shan-Hung Wu CS, NTHU

UNIVERSITI TEKNOLOGI MALAYSIA TEST 1 SEMESTER II 2012/2013

CSS Design and Layout Basic Exercise instructions. Today's exercises. Part 1: Arrange Page into Sections. Part 1, details (screenshot below)

Website Development with HTML5, CSS and Bootstrap

Chapter 3 Style Sheets: CSS

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

Cascading Style Sheets (Part II)

Introduction to Computer Science Web Development

Block & Inline Elements

CSC309 Programming on the Web week 3: css, rwd

Responsive web design (RWD) CSS3 Media queries. Mobile vs desktop web sites. Web Development 1 CS1115/CS5002

Session 4. Style Sheets (CSS) Reading & References. A reference containing tables of CSS properties

Table Basics. The structure of an table

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

Responsive Web Design (RWD)

Web Authoring and Design. Benjamin Kenwright

Media Types & Media Features

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

Cascading Style Sheets for layout II CS7026

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

Fish Eye Menu DMXzone.com Fish Eye Menu Manual

HTML and CSS a further introduction

Note: The screenshots in this document were taken on Windows in Firefox, which may differ from your system.

CSS Handout. CS 4173 Summer about 70 more properties includes all of CSS1 includes properties for non-screen presentation

In this tutorial, we are going to learn how to use the various features available in Flexbox.

CSS مفاهیم ساختار و اصول استفاده و به کارگیری

Produced by. Web Development. Eamonn de Leastar Department of Computing, Maths & Physics Waterford Institute of Technology

Introduction to Computer Science Web Development

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

Creating a CSS driven menu system Part 1

CSS. Lecture 16 COMPSCI 111/111G SS 2018

CS193X: Web Programming Fundamentals

USER GUIDE. MADCAP FLARE 2017 r3. QR Codes

HTML-5.com itemscopehttp://data-vocabulary.org/breadcrumb<span itemprop="title">html 5</span> itemscopehttp://data-vocabulary.

Introduction to WEB PROGRAMMING

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

ID1354 Internet Applications

CSS worksheet. JMC 105 Drake University

Transcription:

Web Programming Step by Step Lecture 5 Floating and Positioning Reading: 4.3-4.5 Except where otherwise noted, the contents of this presentation are Copyright 2009 Marty Stepp and Jessica Miller. 4.3: Floating Elements 4.1: Styling Page Sections 4.2: Introduction to Layout 4.3: Floating Elements 4.4: Sizing and Positioning

The CSS float property (reference) (4.3.1) img.headericon { float: right; width: 130px; } Borat Sagdiyev (born July 30, 1972) is a fictional Kazakhstani journalist played by British-Jewish comedian Sacha Baron Cohen. He is the main character portrayed in the controversial and successful film Borat: Cultural Learnings of America for Make Benefit Glorious... property description float side to hover on; can be left, right, or none (default) removed from normal document flow; underlying text wraps around as necessary Floating elements diagram

Common float bug: missing width I am not floating, no width I am floating right, no width I am not floating, 45% width I am floating right, 45% width often floating block elements must have a width property value if no width is specified, the floating element may occupy 100% of the page width, so no content can wrap around it The clear property (4.3.2) p { background-color: fuchsia; } h2 { clear: right; background-color: yellow; } Homestar Runner is a Flash animated Internet cartoon. It mixes surreal humour with references to 1980s and 1990s pop culture, notably video games, classic television and popular music. My Homestar Runner Fan Site property clear description disallows floating elements from overlapping this element; can be left, right, or none (default)

Clear diagram div#sidebar { float: right; } p { clear: right; } Common error: container too short (4.3.3) <p><img src="images/homestar_runner.png" alt="homestar runner" /> Homestar Runner is a Flash animated Internet cartoon. It mixes surreal humour with...</p> p { border: 2px dashed black; } img { float: right; } Homestar Runner is a Flash animated Internet cartoon. It mixes surreal humour with... We want the p containing the image to extend downward so that its border encloses the entire image

The overflow property (4.3.3) p { border: 2px dashed black; overflow: hidden; } Homestar Runner is a Flash animated Internet cartoon. It mixes surreal humour with... property overflow description specifies what to do if an element's content is too large; can be auto, visible, hidden, or scroll Multi-column layouts (4.3.4) <div> <p>first paragraph</p> <p>second paragraph</p> <p>third paragraph</p> Some other text that is important </div> p { float: right; width: 20%; margin: 0.5em; border: 2px solid black; } div { border: 3px dotted green; overflow: hidden; } Some other text that is important third paragraph second paragraph first paragraph

4.4: Sizing and Positioning 4.1: Styling Page Sections 4.2: Introduction to Layout 4.3: Floating Elements 4.4: Sizing and Positioning The position property (examples) (4.4.2) div#ad { position: fixed; right: 10%; top: 45%; } property value description position top, bottom, left, right static default position relative offset from its normal static position absolute a fixed position within its containing element fixed positions of box's corners Here I am! a fixed position within the browser window

Absolute positioning #sidebar { position: absolute; left: 400px; top: 50px; } removed from normal flow (like floating ones) positioned relative to the block element containing them (assuming that block also uses absolute or relative positioning) actual position determined by top, bottom, left, right values should often specify a width property as well Relative positioning #area2 { position: relative; } absolute-positioned elements are normally positioned at an offset from the corner of the overall web page to instead cause the absolute element to position itself relative to some other element's corner, wrap the absolute element in an element whose position is relative

Fixed positioning removed from normal flow (like floating ones) positioned relative to the browser window even when the user scrolls the window, element will remain in the same place Alignment vs. float vs. position 1. if possible, lay out an element by aligning its content horizontal alignment: text-align set this on a block element; it aligns the content within it (not the block element itself) vertical alignment: vertical-align set this on an inline element, and it aligns it vertically within its containing element 2. if alignment won't work, try floating the element 3. if floating won't work, try positioning the element absolute/fixed positioning are a last resort and should not be overused

Details about inline boxes size properties (width, height, min-width, etc.) are ignored for inline boxes margin-top and margin-bottom are ignored, but margin-left and margin-right are not the containing block box's text-align property controls horizontal position of inline boxes within it text-align does not align block boxes within the page each inline box's vertical-align property aligns it vertically within its block box The vertical-align property property vertical-align description specifies where an inline element should be aligned vertically, with respect to other content on the same line within its block element's box can be top, middle, bottom, baseline (default), sub, super, text-top, text-bottom, or a length value or % baseline means aligned with bottom of non-hanging letters

vertical-align example <p style="background-color: yellow;"> <span style="vertical-align: top; border: 1px solid red;"> Don't be sad! Turn that frown <img src="images/sad.jpg" alt="sad" /> upside down! <img style="vertical-align: bottom" src="images/smiley.jpg" alt="smile" /> Smiling burns calories, you know. <img style="vertical-align: middle" src="images/puppy.jpg" alt="puppy" /> Anyway, look at this cute puppy; isn't he adorable! So cheer up, and have a nice day. The End. </span></p> Don't be sad! Turn that frown upside down! Smiling burns calories, you know. day. The End. Anyway, look at this cute puppy; isn't he adorable! So cheer up, and have a nice Common bug: space under image <p style="background-color: red; padding: 0px; margin: 0px"> <img src="images/smiley.png" alt="smile" /> </p> red space under the image, despite padding and margin of 0 this is because the image is vertically aligned to the baseline of the paragraph (not the same as the bottom) setting vertical-align to bottom fixes the problem (so does setting line-height to 0px)