CSC309 Winter Lecture 2. Larry Zhang

Similar documents
Building Page Layouts

CSS: Cascading Style Sheets

BIM222 Internet Programming

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

Introduction to WEB PROGRAMMING


CSS Cascading Style Sheets

Unveiling the Basics of CSS and how it relates to the DataFlex Web Framework

CSS. Shan-Hung Wu CS, NTHU

NAVIGATION INSTRUCTIONS

COMS 359: Interactive Media

Chapter 3 Style Sheets: CSS

Parashar Technologies HTML Lecture Notes-4

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

Styles, Style Sheets, the Box Model and Liquid Layout

CSS for Page Layout Robert K. Moniot 1

CS7026 CSS3. CSS3 Graphics Effects

Cascading Style Sheets (CSS)

Website Development with HTML5, CSS and Bootstrap

CSS.

CSS Futures. Web Development

Guidelines for doing the short exercises

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar with Dynamic Background Image

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

GIMP WEB 2.0 MENUS WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR CREATING AN HTML LIST

Assignments (4) Assessment as per Schedule (2)

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

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

APPLIED COMPUTING 1P01 Fluency with Technology

CSS Cascading Style Sheets

CSC309 Programming on the Web week 3: css, rwd

Using Dreamweaver CC. Logo. 4 Creating a Template. Page Heading. Page content in this area. About Us Gallery Ordering Contact Us Links

In the early days of the Web, designers just had the original 91 HTML tags to work with.

HTML & CSS. Rupayan Neogy

Web Design and Development Tutorial 03

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

Frontend guide. Everything you need to know about HTML, CSS, JavaScript and DOM. Dejan V Čančarević

the missing manual0 O'REILLY Third Edition David Sawyer McFarland Beijing Cambridge The book that should have been in the box Farnham

COMS 359: Interactive Media

Deccansoft Software Services

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100

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

COMP519 Web Programming Lecture 7: Cascading Style Sheets: Part 3 Handouts

ADDING CSS TO YOUR HTML DOCUMENT. A FEW CSS VALUES (colour, size and the box model)

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

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

CSS Box Model. Cascading Style Sheets

Universal CSS Navigation Menu: Advanced Styling Patrick Julicher Universal CSS Navigation Menu: Advanced Styling

HTML and CSS a further introduction

Certified CSS Designer VS-1028

Website Design (Weekend) By Alabian Solutions Ltd , 2016

Introduction to CSS. 2 Sep 13. Derek Peacock. An introduction to defining CSS style rules using tags, classes and ids.

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

ITNP43: HTML Lecture 4

HTML + CSS. ScottyLabs WDW. Overview HTML Tags CSS Properties Resources

Lab Introduction to Cascading Style Sheets

Web Design and Implementation

READSPEAKER ENTERPRISE HIGHLIGHTING 2.5

IBM Forms V8.0 Custom Themes IBM Corporation

CSS: Beyond the Code. Karen Perone Rodman Public Library.

CSS: Cascading Style Sheets

Cascading Style Sheets CSCI 311

Tutorial 3: Working with Cascading Style Sheets

Creating and Building Websites

Web Engineering CSS. By Assistant Prof Malik M Ali

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

CSS: formatting webpages

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web

HTML and CSS COURSE SYLLABUS

ID1354 Internet Applications

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

Using Dreamweaver CS6

CS193X: Web Programming Fundamentals

Unit 20 - Client Side Customisation of Web Pages. Week 2 Lesson 3 Introduction to CSS

Web Programming and Design. MPT Senior Cycle Tutor: Tamara Week 2

CMPT 165 Advanced XHTML & CSS Part 3

Table Basics. The structure of an table

Web Design & Dev. Combo. By Alabian Solutions Ltd , 2016

Cascading Style Sheet. Styles as Tag Attributes. Syntax. <h1>: what font type/size is used? STYLE = SELECTOR {RULES} Attributes such as bgcolor

Cascading Style Sheets Level 2

Flash Image Enhancer Manual DMXzone.com Flash Image Enhancer Manual

Designing the Home Page and Creating Additional Pages

Using Dreamweaver CS6

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

COMP519 Web Programming Lecture 6: Cascading Style Sheets: Part 2 Handouts

epromo Guidelines DUE DATES NOT ALLOWED PLAIN TEXT VERSION

Ministry of Higher Education and Scientific Research

Before you begin, make sure you have the images for these exercises saved in the location where you intend to create the Nuklear Family Website.

Navigation. Websites need a formalized system of links to allow users to navigate the site

INFS 2150 Introduction to Web Development

Website Design (Weekday) By Alabian Solutions Ltd , 2016

INFS 2150 Introduction to Web Development

CSS: The Basics CISC 282 September 20, 2014

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

Comm 244 Week 3. Navigation. Navigation. Websites need a formalized system of links to allow users to navigate the site

CS7026 Media Queries II. Different Screen Size Different Design

IMY 110 Theme 6 Cascading Style Sheets

Introduction to Cascading Style Sheet (CSS)

Unit 10 - Client Side Customisation of Web Pages. Week 5 Lesson 1 CSS - Selectors

Transcription:

CSC309 Winter 2016 Lecture 2 Larry Zhang 1

Announcements Assignment 1 is out, due Jan 25, 10pm. Start Early! Work in groups of 2, make groups on MarkUs. Make sure you can login to MarkUs, if not let me know. Tutorial 1 this Wednesday, very important! You will setup your personal web space on cs.utm servers. You will exercise with HTML and CSS, which is what A1 is about. Consider go to the 6-7pm section, fewer people, more help. If you are from StG, email me your UTORID so I can create account for you on cs.utm servers. 2

Cascading Style Sheets 3

Why CSS? For each element that we have in the HTML file, we want to define some style for it. size color position margin alignment etc... 4

The primitive way of styling What s bad about this? 5

Why CSS We would like to decouple the code that describes What information is displayed How the information is displayed HTML file CSS file Because of the separation, one CSS file can control the style of multiple HTML files. Decoupling is an important idea in software engineering! 6

Using a stylesheet file, e.g., style.css <head> <link href= style.css type= text/css rel= stylesheet /> </head> One HTML file can include multiple stylesheets. What if have conflicts? Good question. Will talk about it later. 7

Can also embed into HTML file Avoid using in general. Only for quick-and-dirty tests. 8

demo http://www.csszengarden.com/ 9

Basic CSS Rule Syntax selector { property: value; property: value; The HTML elements selected by the selector have style define by all the property-value pairs.... property: value; } 10

Selectors 11

Select all elements of a kind p { font-size:100px; color:red; font-weight:bold; } All <p> elements in HTML have font size 100px, red color and are boldface. 12

You can group different selectors (use comma) p, h1 { color:red; } All <p> and <h1> elements in HTML have red colour. 13

Select A inside B (use space) <p>the red paragraph</p> <div> <p>i want to be blue!</p> </div> div p { color:blue; All <p> inside <div> have blue colour. } 14

Care about immediate parent (use > ) <div> <span><p>i won t turn blue!</p></span> </div> <div> <p>i am blue.</p> div > p { color:blue; </div> } select <p> whose immediate parent is a <div> 15

Select according attribute (use [attr]) <a target= _blank href= x.html >I m blue.</a> <a href= x.html >I don t turn blue</a> a[target] { color:blue; } select <a> who has target attribute 16

Select elements under some special state a:hover { color:blue; } <a> turns blue when hovered over by mouse. 17

Pseudo classes 18

How to select this? <p>a normal paragraph</p> <p>i want to be different!</p> Hard to find a selector that distinguishes these two. The ugly way <p>a normal paragraph</p> <p style= color:blue; >I want to be different!</p> 19

The better way: use id or class attributes <p>a normal paragraph</p> <p id= different >I want to be different!</p> #different { color:blue; } Select the element with id different 20

Use class <p>a normal paragraph</p> <p class= different >I want to be different!</p>.different { color:blue; } Select the element with class different 21

id vs class id must be unique, i.e., one id can only be used once by a single element. one class name can be used by multiple elements 22

* { color:blue; } p * { color:blue; } 23

Full list of CSS selectors http://www.w3schools.com/cssref/css_selectors.asp CSS selector (fun) exercises http://flukeout.github.io/ 24

Takeaway: what are the pros of using selectors compared to one selector can select multiple elements, so don t need write the same style multiple times. one element can be of multiple class and combine multiple styles In general, it is better organized and more flexible Javascript works well with selectors, too. 25

Cascading Style Sheets What is cascading about? 26

Cascading More than one stylesheet rules could be applied to an HTML element We need a way to determine which rule actually has effect. The general rule is to cascade down from more general rules to more specific rules, i.e., the more specific rule is chosen. 27

Example <div> <p>what s my colour?</p> p { </div> color:red; } div p { color:blue; This rule is more specific, so the colour is blue. } 28

Cascading: more details Later rules override earlier rules (with everything else being equal) Closer rules override farther rules inline rules override rules embedded in the head, which overrides rules defined in external stylesheet more specific rules override more general rules an element inherits the style of its container The exact calculation: http://www.blooberry.com/indexdot/css/topics/cascade.htm Your code should be so simple and clear that no complicated calculation is need to determine which one overrides. 29

We re done talking about selectors selector { property: value; property: value;... property: value; } Let s talk about properties and values. 30

the style properties that you can set 31

colours 32

Specifying colours 33

Fonts Full list of font properties: http://www.w3schools.com/css/css_font.asp 34

Font family 35

Font family 36

Font size 37

Using em is recommended by W3C Font size 38

font-weight, font-style 39

CSS properties for text Full list of text properties: http://www.w3schools.com/css/css_text.asp 40

text-align 41

text-decoration 42

CSS properties for background 43

background-image 44

background-repeat 45

background-position 46

Just look it up here when needed http://www.w3schools.com/css/default.asp 47

Page Layout with CSS 48

The CSS Box Model 49

The CSS Box Model: more details 50

Related properties of the box model padding //for all 4 sides padding-left padding-right padding-top padding-bottom margin //for all 4 sides margin-left margin-right margin-top margin-bottom border: 5px solid red; width, height: note this is only for the content part, the real width/height of the whole box is more than the defined value (+padding+border+margin) 51

More about width width changes with browser size limit the range of change 52

Float 53

The normal document flow inline elements block elements 54

The normal document flow: with both 55

Float 56

document flow with float 57

clear disallows the floating element to overlap with the element that clears 58

document flow with clear 59

common bug: float with no width 60

common bug: container too short 61

fix it: using overflow: hidden (or auto) 62

Multi-column layout 63

Position 64

The position property 65

MUST READ & TRY great tutorial with positioning examples http://www.barelyfitz.com/screencast/html-training/css/positioning/ 66

display and visibility 67

display 68

visibility 69

display:none; vs visibility:hidden; display:none; makes an element take NO space visibility:hidden; still takes the space but just you can t see it div1 div1 div3 div3 70

Takeaway: box model, doc flow... Before you learn these things, you may have had your CSS kind-of working by try-change-it-and-see-what-happens (change margin or padding? don t care), that typically leads to broken ugly layouts, without you realizing it. Now you learned these things, you should do everything in the principled way. 71

CSS3 the latest standard of CSS 72

CSS3 CSS3 is completely backward-compatible with old version of CSS, and added a bunch of new features, such as round corners gradients shadows animation media queries 73

Rounded corner We used to have to do this: -moz-border-radius: 10px 5px; Now we do this border-radius: 10px 5px; -webkit-border-top-left-radius: 10px; -webkit-border-top-right-radius: 5px; -webkit-border-bottom-right-radius: 10px; -webkit-border-bottom-left-radius: 5px; border-radius: 10px 5px; 74

Media Query Useful for responsive design, i.e., change the page style dynamically according to the screen size. For example: demo link: http://www.w3schools.com/css/css3_mediaqueries.asp 75

CSS3 Animation No need of Javascript. Demo https://daneden.github.io/animate.css/ 76

77

Assignment 1 One HTML, two stylesheets 78

Assignment 1 make sure to satisfy all the requirement try to make it good-looking can add additional features, without violating any requirements Ask me whenever there is something unclear. For source code management, the department can only do SVN right now, which is not good So, recommendation: use Bitbucket (http://bitbucket.org) to create a shared GIT or Mercurial repository with your partner. Make you project PRIVATE! 79

The minimalist GIT tutorial The GIT book: https://git-scm.com/book/en/v2 Why you should use git: https://www.youtube.com/watch?v=4xpnkhjaok8 GIT SVN git clone <repo URL> svn checkout <repo URL> git pull origin master svn update git add <filename> svn add <filename> git commit -am <log text> git push origin master git status svn commit -m <log text> svn status 80

Google Font Easy way to get fancy fonts. https://www.google.com/fonts You can use it for Assignment 1. 81

Today we learned CSS Next week: Javascript 82