Floating Elements CS380 1. The CSS float property (reference) 2 img.headericon { float: right; width: 130px; } CSS  removed from normal document flow;

Slides:



Advertisements
Similar presentations
LIS650 lecture 4 Thomas Krichel today CSS Properties –Box properties-- List properties –Table properties-- Classification properties –(Audio.
Advertisements

1 Cascading Style Sheets Continued Different kinds of selectors in a style sheet –Simple- Pseudo-Class –Contextual- Pseudo-Element –Class Image Styles.
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.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Layout using CSS. Using multiple classes In the head:.important{font-style:italic;}.title{color:red;} In the body: Here's a type of paragraph that is.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
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.
CIS 1310 – HTML & CSS 6 Layout. CIS 1310 – HTML & CSS Learning Outcomes  Describe & Apply the CSS Box Model  Configure Float with CSS  Designate Positioning.
Floating Elements CS380.
Cascading Style Sheets Color and Background Controls Border and Margin Controls (Boxes)
Tutorial 4: Creating page layout with css
Today’s objectives Site performance Padding, Margins, Borders
Week 9 Using the Box Properties. 9-2 The CSS Visual Formatting Model Describes how the element content boxes should be displayed by the browser –Based.
Text Properties, Line Box, CSS. Text Properties Properties related to the display of text. Text-align : left, right, center I like FSU!
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.
An Introduction to Cascading Style Sheets CSS Layout, and the CSS Box Model Nick Foxall SM5312 week 9: CSS Layout.
MORE Cascading Style Sheets (The Positioning Model)
14-Jul-15 CSS Applications to XML. 2 A different emphasis CSS is the same for XML as it is for HTML, but-- HTML already does a pretty good job of layout.
1 CS428 Web Engineering Lecture 10 Images, Tables, Forms, Border-Radius (CSS – V)
Svetlin Nakov Telerik Web Design Course html5course.telerik.com Manager Technical Training
Slide 1 of 83 Table Borders To specify table borders in CSS, use the border property. The example below specifies a black border for table, th, and td.
LING 408/508: Programming for Linguists
Principles of Web Design 6 th Edition Chapter 7 – Page Layouts.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
Copyright © Terry Felke-Morris CSS Flow & Positioning 1 Copyright © Terry Felke-Morris.
Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border 
 Website development process  CSS  Javascript.
CSS = Cascading Style Sheet CSS consists of rules to display, style and decorate HTML elements Why CSS ? – Separate decoration from HTML markup (Ex :,,…)
CSE 154 LECTURE 4: FLOATING AND POSITIONING. The CSS float property propertydescription floatside to hover on; can be left, right, or none (default) a.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 Chapter 6 Key Concepts 1 Copyright © Terry Felke-Morris.
Svetlin Nakov Telerik Corporation
Week 8 – Part 2 Page Layout Basics Key Concepts 1.
THE BOX MODEL Putting layouts together with CSS. The Box Model  How would you describe a box?  Container?  Tags or elements are “containers”  puts.
1 CS428 Web Engineering Lecture 08 Border, Margin, Padding … (CSS - III)
LING 408/508: Programming for Linguists Lecture 10 September 30 th.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
CSS Fun damentals The Document Hierarchy Element Relationships The Box Model.
INTRODUCTORY Tutorial 5 Using CSS for Layout and Printing.
CSS Layout Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  float & clear  display & visibility.
CSS Positioning & Layout Creating layouts and controlling elements.
CONTROLLING Page layout
Tutorial 4 Creating Page Layouts with CSS
5 th ed: Chapter 4 4 th ed: Chapter 5 SY306 Web and Databases for Cyber Operations SlideSet #5: Advanced CSS.
CSE 154 LECTURE 4: PAGE SECTIONS AND THE CSS BOX MODEL.
CSS - Quiz #3 Lecture Code:
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring 2016 CSS Positioning 1.
HTML and Dreamweaver November 11th. Agenda Box Model Displaying and positioning elements – Padding – Margin – Float – Display – Position HTML Demo.
Today’s objectives  Announcements  Positioning  Measurement units.
Week 5.  Normal document flow  Affecting document flow with float and position properties using CSS  Using these properties to create layouts.
PERSPECTIVES: TUTORIAL 4 CREATING PAGE LAYOUTS WITH CSS.
Chapter 7.  Change body and link styles  Create a drop-down menu  Change color and font styles in the menu  Create a pop-up effect using CSS  Utilize.
CS 120: Introduction to Web Programming Lecture 10: Extra Features and Website Design Part 1 Tarik Booker CS 120 California State University, Los Angeles.
HTML 5 AND CSS Dr Mohd Soperi Mohd Zahid Semester /16.
1 CS428 Web Engineering Lecture 07 Font, Text & Background (CSS - II)
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.
Cascading Style Sheets Layout
CSS Layouts CH 13.
CSS Layouts: Grouping Elements
Webpage layout using CSS
Floating & Positioning
Lecture 5: Floating and Positioning
Controlling Layout with Style Sheets
MORE Cascading Style Sheets (The Positioning Model)
Floating and Positioning
CSc 337 Lecture 4: Positioning.
CMPT241 Web Programming More CSS: Page Layout.
CSc 337 Lecture 5: Grid layout.
Positioning Boxes Using CSS
Presentation transcript:

Floating Elements CS380 1

The CSS float property (reference) 2 img.headericon { float: right; width: 130px; } CSS  removed from normal document flow; underlying text wraps around as necessary Ghostbusters is a 1984 American science fiction comedy film written by co-stars Dan Aykroyd and Harold Ramis about three eccentric New York City parapsychologists-turned-ghost capturers. output

Floating elements diagram CS380 3

Common float bug: missing width  often floating block elements must have a width property value  Let’s try “floating” Let’s try “floating” CS380 4

The clear property CS380 5 p { background-color: fuchsia; } h2 { clear: right; background-color: yellow; } CSS Mario is a fictional character in his video game series. Serving as Nintendo's mascot and the main protagonist of the series, Mario has appeared in over 200 video games since his creation. output Super Mario Fan Site! Mario is a fictional character in his video game series. Serving as Nintendo's mascot and the main protagonist of the series, Mario has appeared in over 200 video games since his creation

The clear property (cont.) CS380 6

Clear diagram CS380 7 div#sidebar { float: right; } p { clear: right; } CSS

Common error: container too short 8 Mario is a fictional character in his video game series..... HTML Mario is a fictional character in his video game series. Serving as Nintendo's mascot and the main protagonist of the series, Mario has appeared in over 200 video games since his creation. output p { border: 2px dashed black; } img { float: right; } CSS

The clear property:  Experimentation! Experimentation! CS380 9

The overflow property 10 Mario is a fictional character in his video game series. Serving as Nintendo's mascot and the main protagonist of the series, Mario has appeared in over 200 video games since his creation. output p { border: 2px dashed black; overflow: hidden; } CSS CS380

The overflow property (cont.) 11 CS380

Multi-column layouts 12 first paragraph second paragraph third paragraph Some other text that is important HTML Some other text that is important output p { float: right; width: 25%; margin: 0.5em; border: 2px solid black; } div { border: 3px dotted green; overflow: hidden; } CSS second paragraphfirst paragraphthird paragraph

Overflow experiments  Overflowing Overflowing CS380 13

Sizing and Positioning 14 CS380

The position property (examples) 15 div#ad { position: fixed; right: 10%; top: 45%; } CSS

Absolute positioning 16 #sidebar { position: absolute; left: 400px; top: 50px; } CSS  removed from normal flow  positioned relative to the block element containing them  actual position determined by top, bottom, left, right  should often specify a width property as well CS380

Relative positioning 17 #area2 { position: relative; } CSS  absolute-positioned elements are normally positioned at an offset from the corner of the overall web page  to make the absolute element to position itself relative to some other element's corner, wrap the absolute element in an element whose position is relative CS380

Fixed positioning 18 #area2 { position: relative; } CSS  removed from normal flow  positioned relative to the browser window even when the user scrolls the window, element will remain in the same place  Play it! Play it!  Try it! Try it! CS380

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 19

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 ignored CS380 20

Details about inline boxes  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 CS380 21

The vertical-align property CS  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 23 Don't be sad! Turn that frown upside down! Smiling burns calories, you know. Anyway, look at this cute puppy; isn't he adorable! So cheer up, and have a nice day. The End. HTML CS380

vertical-align example (cont.) 24 CS380

Common bug: space under image 25 HTML  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)

vertical-align experiments  Play it Play it  And of course… try it!!try it CS380 26

The display property 27 h2 { display: inline; background-color: yellow; } CSS  values: none, inline, block, run-in, compact,...  use sparingly, because it can radically alter the page layout output CS380

The display property (cont.) 28 p.secret { visibility: hidden; } CSS  hidden elements will still take up space onscreen, but will not be shown  to make it not take up any space, set display to none instead  can be used to show/hide dynamic HTML content on the page in response to events output CS380

The display property 29 #topmenu li { display: inline; border: 2px solid gray; margin-right: 1em; } CSS  lists and other block elements can be displayed inline  flow left-to-right on same line  width is determined by content output Item 1 Item 2 Item 3 HTML