CGS 3066: Web Programming and Design Fall 2019 CSS Part 2

Slides:



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

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.
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.
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.
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.
MORE Cascading Style Sheets (The Positioning Model)
1 The Structure of a Web Table beginning of the table structure first row of three in the table end of the table structure table cells You do not need.
Web Development & Design Foundations with XHTML Chapter 6 Key Concepts.
ITP 104.  While you can do things like this:  Better to use styles instead:
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.
Lecture 2 - HTML and CSS Review SFDV3011 – Advanced Web Development 1.
Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.
CSS Fun damentals The Document Hierarchy Element Relationships The Box Model.
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.
Cascading Style Sheets (CSS) Part II IT210: Web-based IT.
CONTROLLING Page layout
Extra-simplified.  Only truly happen when the CSS and HTML are defined as separate files (external style sheet) Introduction The main idea of CSS is.
Tutorial 4 Creating Page Layouts with CSS
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring 2016 CSS Positioning 1.
CIS67 Foundations for Creating Web Pages Professor Al Fichera Rev. September 22, 2010—All HTML code brought to XHTML standards. Reference for CIS127 and.
HTML and Dreamweaver November 11th. Agenda Box Model Displaying and positioning elements – Padding – Margin – Float – Display – Position HTML Demo.
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.
Ch 11 HTML and CSS Web Standards Solutions A Web Standardistas’ Approach.
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.
Laying out Elements with CSS
CSS Box Model.
CSS Box Model.
CSS Box Model.
The Box Model in CSS Web Design – Sec 4-8
Cascading Style Sheets Boxes
( Cascading style sheet )
CSS Layouts: Positioning and Navbars
Table Styling.
Table Styling.
The Box Model in CSS Web Design – Sec 4-8
CSS Layouts: Grouping Elements
Table Styling.
Webpage layout using CSS
>> The “Box” Model
Cascading Style Sheets (Layout)
The Box Model in CSS Web Design – Sec 4-8
>> CSS Layouts.
The Internet 10/25/11 XHTML Tables
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Objectives Create a reset style sheet Explore page layout designs
6 Layout.
Creating Layouts Using CSS
Cascading Style Sheets
Styles and the Box Model
Fixed Positioning.
CSS Borders and Margins.
Positioning.
MORE Cascading Style Sheets (The Positioning Model)
CSS Box Model.
Web Development & Design Foundations with H T M L 5
Web Development & Design Foundations with H T M L 5
More CSS Page layout Boriana Koleva Room: C54
SEEM4570 Tutorial 3: CSS + CSS3.0
Floating and Positioning
CSS Box Model.
Principles of Web Design 5th Edition
Positioning.
Laying out Elements with CSS
CSS Box Model.
CSS Box Model.
The div Element and CSS for layout
CSc 337 Lecture 5: Grid layout.
Positioning Boxes Using CSS
Presentation transcript:

CGS 3066: Web Programming and Design Fall 2019 CSS Part 2 Department of Computer Science, Florida State University

The CSS Box Model All printable HTML elements can be represented as rectangular boxes Each box consist of the following spaces: Content Area: displays the actual text/graphic Padding: spaces surrounding the content area Border: Surrounds contents and padding Margin: spaces to separate an element from other adjacent elements or its container

The CSS Box Model Content Padding Border Margin

The CSS “containing element” Each element has an associated containing element “each box sits inside some bigger box” Only block level elements(<div>,<table>,<h1>..<h6> etc) or the webpage itself(<html> tag) are considered as containing element In case of multiple block-level nesting, the containing element of a box/element will be the closest block level element Will be referred as simply ‘container’

CSS Width and height properties height: [length units] width: [length units] Used to set width and height of the Content Area of an Element div{ height: 100px; width: 300px; } Length values can be absolute(in,cm,mm,px) or % of the height/width of its container

CSS Padding properties padding-top: [length units] padding-right:[length units] padding-bottom:[length units] padding-left:[length units] Shorthand expression: padding: [top][right][bottom][left] Start from top and go clockwise

Shorthand format Typing out all of these properties out can be tiresome, so CSS provides an alternative “shorthand” form of the padding property that lets you set the top/bottom and left/right padding with only one line of CSS. p { padding: 20px 10px; } Vertical Horizontal

CSS Margin properties margin-top: [length units] margin-right:[length units] margin-bottom:[length units] margin-left:[length units] Similar to padding, property margin can set all 4 values in top-right-bottom-left sequence

CSS Borders border-width: [length units] border-style: [none/hidden/dotted/dashed/solid/double/groove/ridge/inset/outset] To Add style to specific side of a border: border-top-style,border-bottom-style .. border-color: [color value] Similarly, border-top-color, border-left-color etc. border-width: [length units] Applies uniform width to all four borders. Customizable Shorthand expression: border: [border-width value] [border-style value] [border-color value]

CSS Borders And this one creates a thick, dotted green border: h1 { border: 1px solid red; } And this one creates a thick, dotted green border: h1 { border: 4px dotted green; } Heading Heading

CSS Borders border-collapse: [collapse/separate] Applies to Table elements If separate, adjacent cells each have their own distinct borders. If collapsed, adjacent table cells share borders.

Default HTML Layout By default, all visible elements of a web page is displayed in the same sequence they are written in HTML Page width filled from left to right, then height filled from top to bottom

HTML vs CSS Positioning How to design multi-column layouts on a web page? Use <table> Add content blocks as table data not recommended Alternatively, use CSS positioning properties

CSS float Property float: [left/right/none] Places the selected element at the left or right side of its container Other texts and inline elements of the container will wrap around it Widely used

CSS float Property By default, block-level elements occupy the entire available width of its container Try printing a small <div> with a background color! Replace <div> with <span> and compare! To make the block–level elements float, it should be ‘shrunk’ by setting appropriate width property

CSS float Property #div1 { float:right; width:300px; height:300px; background-color:red; border-style:solid" } <p id=“para1”> <div id=“div1”> floated<br>text</div> Loren ipsum …. laborum </p>

CSS clear Property clear: [left/right/both] Prevents placement of floating element on the [left/right/both] side of the selected element Useful to clear past floating elements and resume normal flow

CSS clear Property #para2{ clear:both; border-style:solid; border-color:blue } <p id=“para1”> <div id=“div1”> floated<br>text</div> Loren ipsum …. Pariatur <p id=“para2”> Instead of …it’s right </p> </p>

CSS position property position: [static|absolute|fixed|relative] Position value static suggests default, normal flow. To use absolute/fixed/relative option, one or two of the following must be set: top: [length units] bottom: [length units] left: [length units] right: [length units] Specifies exact placement location for the selected element

CSS position property(contd.) absolute: Positioning values measured from the edge of the entire HTML document fixed: Positioning values are calculated from the edge of the viewport. User always sees a fixed element in the same location of his page view Relative: Positioning values are calculated from the edges of the nearest positioned container Example: http://learnlayout.com/position-example.html