Style & Layout in the web: CSS and Bootstrap



Similar documents
Using Style Sheets for Consistency

Web Design Basics. Cindy Royal, Ph.D. Associate Professor Texas State University

Web Design and Databases WD: Class 7: HTML and CSS Part 3

Outline of CSS: Cascading Style Sheets

Web Design with CSS and CSS3. Dr. Jan Stelovsky

Web Design & Development - Tutorial 04

HTML CSS Basic Structure. HTML Structure [Source Code] CSS Structure [Cascading Styles] DIV or ID Tags and Classes. The BOX MODEL

Chapter 7 Page Layout Basics Key Concepts. Copyright 2013 Terry Ann Morris, Ed.D

Last week we talked about creating your own tags: div tags and span tags. A div tag goes around other tags, e.g.,:

CREATING HORIZONTAL NAVIGATION BAR USING ADOBE DREAMWEAVER CS5

What is CSS? Official W3C standard for controlling presentation Style sheets rely on underlying markup structure

JJY s Joomla 1.5 Template Design Tutorial:

Web Development 1 A4 Project Description Web Architecture

Web Building Blocks. Joseph Gilbert User Experience Web Developer University of Virginia Library

Slicing and Coding the Navigation Background in CSS

Essential HTML & CSS for WordPress. Mark Raymond Luminys, Inc mraymond@luminys.com

Web Authoring CSS. Module Descriptor

COMMONWEALTH OF PENNSYLVANIA DEPARTMENT S OF Human Services, INSURANCE, AND AGING

CSS - Cascading Style Sheets

CSS for Page Layout. Key Concepts

CHAPTER 10. When you complete this chapter, you will be able to:

ITNP43: HTML Lecture 4

Inspiring Creative Fun Ysbrydoledig Creadigol Hwyl. Web Design in Nvu Workbook 2

Web Development CSE2WD Final Examination June (a) Which organisation is primarily responsible for HTML, CSS and DOM standards?

CSS 101. CSS CODE The code in a style sheet is made up of rules of the following types

Web Design I. Spring 2009 Kevin Cole Gallaudet University

Responsive Web Design Creative License

Web Design and Development ACS Chapter 9. Page Structure

Dreamweaver CS4 Day 2 Creating a Website using Div Tags, CSS, and Templates

ICE: HTML, CSS, and Validation

Using an external style sheet with Dreamweaver (CS6)

Web Design Revision. AQA AS-Level Computing COMP2. 39 minutes. 39 marks. Page 1 of 17

Garfield Public Schools Fine & Practical Arts Curriculum Web Design

How to Properly Compose HTML Code : 1

{color:blue; font-size: 12px;}

CST 150 Web Design I CSS Review - In-Class Lab

How To Create A Web Page On A Windows (For Free) With A Notepad) On A Macintosh (For A Freebie) Or Macintosh Web Browser (For Cheap) On Your Computer Or Macbook (

Positioning Container Elements

Building a Horizontal Menu in Dreamweaver CS3 Using Spry R. Berdan

Creating the Surf Shop website Part3 REVISED

FETAC Certificate in Multimedia Production. IBaT College Swords. FETAC Certificate in Multimedia Production Web Authoring Dreamweaver 3

Principles of Web Design 6 th Edition. Chapter 12 Responsive Web Design

CREATING A NEWSLETTER IN ADOBE DREAMWEAVER CS5 (step-by-step directions)

Create Your own Company s Design Theme

Building Responsive Websites with the Bootstrap 3 Framework

SAULT COLLEGE OF APPLIED ARTS AND TECHNOLOGY SAULT STE. MARIE, ONTARIO COURSE OUTLINE

Development Perspective: DIV and CSS HTML layout. Web Design. Lesson 2. Development Perspective: DIV/CSS

Cascading Style Sheets (CSS)

CSS. CSS - cascading style sheets CSS - permite separar num documento HTML o conteúdo do estilo. ADI css 1/28

Table of Contents. What is ProSite? What is Behance? How do ProSite & Behance work together? Get Started in 6 Easy Steps.

WHITEPAPER. Skinning Guide. Let s chat Velaro info@velaro.com by Velaro

Fast track to HTML & CSS 101 (Web Design)

This document will describe how you can create your own, fully responsive. drag and drop template to use in the creator.

Designing HTML s for Use in the Advanced Editor

Selectors in Action LESSON 3

Web Development. Owen Sacco. ICS2205/ICS2230 Web Intelligence

Coding HTML Tips, Tricks and Best Practices

Coding Standards for Web Development

Further web design: Cascading Style Sheets Practical workbook

Simply download Beepip from and run the file when it arrives at your computer.

CIS 467/602-01: Data Visualization

Basic tutorial for Dreamweaver CS5

Web layout guidelines for daughter sites of Scotland s Environment

Dreamweaver Domain 2: Planning Site Design and Page Layout

Kentico CMS, 2011 Kentico Software. Contents. Mobile Development using Kentico CMS 6 2 Exploring the Mobile Environment 1

1 of 8 9/14/2011 5:40 PM

Mobile Web Site Style Guide

Base template development guide

Introduction to Web Design Curriculum Sample

Script Handbook for Interactive Scientific Website Building

<Insert Picture Here>

MAGENTO THEME SHOE STORE

SAHARA DIGITAL8 RESPONSIVE MAGENTO THEME

Campaign Guidelines and Best Practices

Responsive Web Design: Media Types/Media Queries/Fluid Images

The Training Floor s. Webmaster s. Bible

We automatically generate the HTML for this as seen below. Provide the above components for the teaser.txt file.

Stylesheet or in-line CSS CSS attributes, used in stylesheets or in-line, can define:

Professional & Workgroup Editions

Creative Guidelines for s

Website Planning Checklist

Table of Contents Find out more about NewZapp

WEB PROGRAMMING LAB (Common to CSE & IT)

WEB DEVELOPMENT IA & IB (893 & 894)

RESPONSIVE DESIGN BY COMMUNIGATOR

Building Your First Drupal 8 Company Site

HTML Tables. IT 3203 Introduction to Web Development

Why? Mobile. 0Your content is no more than 3 taps away from Angry Birds. 0 Many people access your website via smartphones and other mobile devices

Website Login Integration

CSS Techniques: Scrolling gradient over a fixed background

Magento Responsive Theme Design

Basics of HTML (some repetition) Cascading Style Sheets (some repetition) Web Design

Web Development I & II*

Web Design for Programmers. Brian Hogan NAPCS Slides and content 2008 Brian P. Hogan Do not reproduce in any form without permission

Contents. Downloading the Data Files Centering Page Elements... 6

Building Responsive Layouts

WRITE BETTER HTML BY WRITING BETTER CSS

Responsive Web Design (RWD) Best Practices Guide Version:

The Essential Guide to HTML Design

Transcription:

Style & Layout in the web: CSS and Bootstrap Ambient intelligence: technology and design Fulvio Corno Politecnico di Torino, 2014/2015

Goal Styling web content Advanced layout in web pages Responsive layouts Libraries 2

Summary CSS Cascading Style Sheets The Bootstrap framework 3

Style & Layout in the web CSS CASCADING STYLE SHEETS 4

Cascading Style Sheets CSS: Cascading Style Sheet CSS 1: W3C recommendation (17 Dec 1996) CSS 2.1: W3C Recommendation (7 June 2011) CSS 3: Working Draft Resources: CSS 2.1 standard, http://www.w3.org/tr/css21/ W3C CSS Home: http://www.w3.org/style/css/ W3C CSS Tutorial, http://www.w3.org/style/examples/011/firstcss 5

CSS Syntax CSS is based on rules A rule is a statement about one stylistic aspect of one or more XHTML elements A style sheet is a set of one or more rules that apply to an XHTML document 6

Cascading Style Sheets The term cascading means that a document can include more than one style sheet In this case, visualization follows priority rules 7

External style Link to an external style sheet using the <link> element style.css h1 { font-size:17px; font-family:verdana; color:green; } h2 { font-size:18px; font-family:arial; color:red; } <head> <link rel=stylesheet type="text/css" href="style.css"> </head> <body> <h1>green text on verdana 17 pixel font</h1> <h2>red text on arial a 18 pixel font</h2> </body> 8

External style Alternative method @import directive in the <style> element <head> <style> @import url(style.css); </style> </head> <body>... </body> 9

Internal style <style> element inside the document header <head> <style type="text/css"> h1 { font-size:17px; font-family:verdana; color:green; } h2 { font-size:18px; font-family:arial; color:red; } </style> </head> 10

Inline style <style> attribute within an XHTML element <h1 style="font-size:17px; font-family:verdana; color:green; "> Green text on verdana 17 pixel font </h1> 11

Priority rules Rules can be marked as important h1 { color:red!important } 12

Tree structure and inheritance XHTML documents are trees Styles are inherited along trees When two rules are in conflict the most specific wins Example body {color: green} h1 {color: red} 13

Main Selectors Selector E.cc #uu HTML <E> <E class="cc"> <E id="uu"> 14

15 http://www.w3.org/tr/css-2010/#selectors

Pseudo class selector Used to style an element based on something other than the structure of the document E.g., the state of a form element or link /* makes all unvisited links blue */ a:link {color:blue;} /* makes all visited links green */ a:visited {color:green;} /* makes links red when hovered or activated */ a:hover, a:active {color:red;} /* makes table rows red when hovered over */ tr:hover {background-color: red;} /* makes input elements yellow when focus is applied */ input:focus {background-color:yellow;} 16

Meaningful XHTML Meanginful elements h1, h2,... ul, ol, and dl strong and em blockquote and cite abbr, acronym, and code fieldset, legend, and label caption, thead, tbody, and tfoot HTML5 adds many new semantic elements id and class names Allow to give extra meaning div and span Add structure to document 17

DIV element Stands for division Used to group block-level elements Provides a way of dividing a document into meaningful areas Use only if necessary and not redundant <div id="mainnav"> <ul> <li>home</li> <li>about Us</li> <li>contact</li> </ul> </div> <ul id="mainnav"> <li>home</li> <li>about Us</li> <li>contact</li> </ul> 18

SPAN element Used to group or identify inline elements <h2>where s Durstan?</h2> <p>published on <span class="date">march 22nd, 2005</span> by <span class="author">andy Budd</span></p> 19

The box model One of the cornerstones of CSS Dictates how elements are displayed and, to a certain extent, how they interact with each other Every element on the page is considered to be a rectangular box 20

The box model Content The content of the box, where text and images appear Padding Clears an area around the content The padding is affected by the background color of the box Border A border that goes around the padding and content The border is affected by the background color of the box Margin Clears an area around the border The margin does not have a background color, it is completely transparent 21

Example Padding, borders, and margins are optional and default to zero #mybox { margin: 10px; padding: 5px; width: 70px; } 22

The box model Total element width = width + left padding + right padding + left border + right border + left margin + right margin Total element height = height + top padding + bottom padding + top border + bottom border + top margin + bottom margin Example W3Schools.com http://www.w3schools.com/css/css_boxmodel.asp 23

Positioning schemes Three basic positioning schemes in CSS Normal flow Floats Absolute positioning Unless specified, all boxes start life being positioned in the normal flow The position of an element s box in the normal flow will be dictated by that element s position in the (X)HTML 24

Normal flow Block-level boxes will appear vertically one after the other <div> </div> The vertical distance between boxes is calculated by the boxes vertical margins Inline boxes are laid out in a line horizontally <span> </span> Their horizontal spacing can be adjusted using horizontal padding, borders, and margins Vertical padding, borders, and margins will have no effect on the height of an inline box 25

Display property Allows to control element visualization (block or inline) Changing an inline element to a block element, or vice versa, can be useful for making the page look a specific way Example W3Schools.com http://www.w3schools.com/css/css_display_visibility.asp li {display:inline;} span {display:block;} 26

Box Positioning A block can be positioned in different ways to which correspond different positioning schemes Static: normal block Relative: the offset values are relative to the block position in the normal flow. If a relative block B follows a relative block A, the offset is respect to the position of A without the offset Absolute: the box position is determined by the top, left, right, bottom properties and is relative to the containing block Fixed: the box is fixed with respect to some reference (the ( example viewport as an 27

Relative positioning It is possible to shift one element relative to its starting point by setting a vertical or horizontal position #mybox { position: relative; left: 20px; top: 20px; } 28

Absolute positioning Takes the element out of the flow of the document, thus taking up no space Other elements in the normal flow of the document will act as though the absolutely positioned element was never there 29

Fixed positioning A subcategory of absolute positioning A fixed element s containing block is the viewport Allows to create elements that always stay at the same position in the window Note: in case of overlaps the z-index property specifies the stack order of an element (which element should be placed in front of, or behind, the others) 30

Fixed positioning Can be used to create complex frame-like presentations #header { position: fixed; width: 100%; height: 15%; top: 0; right: 0; bottom: auto; left: 0; } #sidebar { position: fixed; width: 10em; height: auto; top: 15%; right: auto; bottom: 100px; left: 0;} #main {position: fixed; width: auto; height: auto; top: 15%; right: 0; bottom: 100px; left: 10em; } #footer {position: fixed; width: 100%; height: 100px; top: auto; right: 0; bottom: 0; left: 0; } 31

Examples W3Schools.com http://www.w3schools.com/css/css_positioning.asp The main problem people have with positioning is remembering which type of positioning is which. Relative positioning is relative to the element s initial position in the flow of the document, whereas absolute positioning is relative to nearest positioned ancestor or, if one doesn t exist, the initial container block. A. Budd, C. Moll, S. Collison, CSS Mastery: Advanced Web Standards Solutions, FriendsOfED, 2006 32

Floating A floated box can either be shifted to the left or the right until its outer edge touches the edge of its containing box, or another floated box Often used for images and when working with layouts Example http://www.w3schools.com/css/css_float.asp img { float:right; } 33

Floating Floated boxes aren t in the normal flow of the document, so block boxes in the regular flow of the document behave as if the floated box wasn t there 34

Floating If all three boxes are floated left Box 1 is shifted left until it touches its containing box Other two boxes are shifted left until they touch the preceding floated box Examples/chapter03/floating-boxes.htm 35

Floating If the containing block is too narrow for all of the floated elements to fit horizontally The remaining floats will drop down until there is sufficient space If the floated elements have different heights, it is possible for floats to get stuck on other 36

Line boxes and clearing Line boxes next to a floated box are shortened to make room for the floated box, and flow around the float Floats were created to allow text to flow around images 37

Line boxes and clearing To stop line boxes flowing around the outside of a floated box, you need to apply a clear to that box The clear property can be left, right, both, or none, and indicates which side of the box should not be next to a floated box p { clear: left } 38

Two-column floated layout 39

Two-column floated layout Better: #content add horizontal { padding width: 520px; float: right; } #mainnav { width: 180px; float: left; } #footer { clear: both; } #mainnav { padding-top: 20px; padding-bottom: 20px; } #mainnav li { padding-left: 20px; padding-right: 20px; } #content h1, #content h2, #content p { padding-right: 20px; } 40

Three-column floated layout (X)HTML framework similar to the two column layout, but two new divs inside the content div <div id="content"> <div id="maincontent"> </div> <div id="secondarycontent"> </div> </div> 41

Three-column floated layout Float the main content left and the secondary content right, inside the already floated content div Divides the second content column in two, creating a three-column effect 42

Three-column floated layout Better: remove the padding from the content #maincontent { element width: and 320px; apply it to the content of the secondary float: left; content } #secondarycontent { width: 180px; float: right; } #secondarycontent h1, #secondarycontent h2, #secondarycontent p { padding-left: 20px; padding-right: 20px; } 43

Three-column floated layout 44

References Andy Budd, Cameron Moll, Simon Collison, CSS Mastery, Advanced Web Standards Solutions www.cssmastery.com/ 45

Style & Layout in the web THE BOOTSTRAP FRAMEWORK 46

Bootstrap Open Source CSS (and Javascript) framework Allows applying modern styles Sensible and nice-looking defaults Easy to apply custom themes Takes care of cross-browser issues Simplified layout model Developed by Twitter http://getbootstrap.com/ 47

Bootstrap philosophy Based on CCS classes Each class applies one effect Various classes may be combined in the same element Wide range of standard classes Wide range of additional components Ready-to use interactive elements or groups of elements Mobile-first Responsive 48

Using Bootstrap 3 files Bootstrap Theme Javascript support Or download locally 49

Page structure Start with Basic template http://getbootstrap.com/getting-started/#template Or, choose from published Examples http://getbootstrap.com/getting-started/#examples 50

Buttons & Menus 51

Tables 52

Navigation bars 53

Grids & Columns 54

License These slides are distributed under a Creative Commons license Attribution NonCommercial ShareAlike (CC BY-NC-SA) 3.0 You are free to: Share copy and redistribute the material in any medium or format Adapt remix, transform, and build upon the material The licensor cannot revoke these freedoms as long as you follow the license terms. Under the following terms: Attribution You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. NonCommercial You may not use the material for commercial purposes. ShareAlike If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. No additional restrictions You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. http://creativecommons.org/licenses/by-nc-sa/3.0/ 55