There are 3 places you can write CSS.

Similar documents
12/9/2012. CSS Layout

COMS 359: Interactive Media

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

Unit 20 - Client Side Customisation of Web Pages. Week 2 Lesson 4 The Box Model

Chapter 3 CSS for Layout

CLASSES are a way to select custom elements without using a tag name

Web Design and Implementation

CSS: Layout, Floats, and More

Using CSS for page layout

CSS Layout Part I. Web Development

Assignments (4) Assessment as per Schedule (2)

Unit 20 - Client Side Customisation of Web Pages. Week 2 Lesson 4 The Box Model

The Importance of the CSS Box Model

Web Authoring and Design. Benjamin Kenwright

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

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

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

Creating Layouts Using CSS. Lesson 9

Cascading Style Sheets CSCI 311

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

Styles, Style Sheets, the Box Model and Liquid Layout

CSS.

CS134 Web Site Design & Development. Quiz1

FLOATING AND POSITIONING

Chapter 6: CSS Layouts

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

Internet Programming 1 ITG 212 / A

Client-Side Web Technologies. CSS Part II

HTML Organizing Page Content

Responsive Web Design (RWD)

CSS means Cascading Style Sheets. It is used to style HTML documents.

Cascading Style Sheets Level 2

Block & Inline Elements

Connected TV Applications for TiVo. Project Jigsaw. Design Draft. 26 Feb 2013

What do we mean by layouts?

Create a three column layout using CSS, divs and floating

CSS: Cascading Style Sheets

Building Page Layouts

Front-End UI: Bootstrap

INTERNATIONAL UNIVERSITY OF JAPAN Public Management and Policy Analysis Program Graduate School of International Relations

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

COMS 359: Interactive Media

Let's take a look at what CSS looks like in Dreamweaver using the "Embedded" coding which is the styles are within the html code and not separate.

Thinking inside the box

To place an element at a specific position on a page use:

CSE 154 LECTURE 5: FLOATING AND POSITIONING

Snapsis CSS NavMenu Development Guide

Media Stylesheets and Navigation with CSS goodness. Webpage Design

Cascading Style Sheets for layout II CS7026

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

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

Introduction to WEB PROGRAMMING

CSS worksheet. JMC 105 Drake University

COMP519 Web Programming Lecture 8: Cascading Style Sheets: Part 4 Handouts

Writing CSS is like directing a film.

HTML and CSS a further introduction

Fixed-width. Liquid. Web Development 1 CS1115/CS5002. Types of layout. relative, fixed), CSS Flexbox layout or CSS Grid Layout

Module 2 (VII): CSS [Part 4]

CSS Web2.0 Search. UNIVERSITY OF MASSACHUSETTS AMHERST CMPSCI 120 Fall Exam #1 graded Exam #2 rescheduled. now tentatively 11/10

CSS: formatting webpages

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

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

CSS Cascading Style Sheets

Web Engineering CSS. By Assistant Prof Malik M Ali

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

BIM222 Internet Programming

AGENDA :: MULTIMEDIA TOOLS :: (1382) :: CLASS NOTES

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

CS193X: Web Programming Fundamentals

READSPEAKER ENTERPRISE HIGHLIGHTING 2.5

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

Using Dreamweaver CS6

HTML and CSS: An Introduction

First Diploma Unit 10 Client Side Web. Week 4 -The CSS Box model

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

HTML Organizing Page Content

Zen Garden. CSS Zen Garden

Deccansoft Software Services

CSS for Page Layout Robert K. Moniot 1

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

The Benefits of CSS. Less work: Change look of the whole site with one edit

HTML and CSS COURSE SYLLABUS

CSC309 Programming on the Web week 3: css, rwd

Class 9 / Instructor: Ira Epstein

Introducing CSS Flexbox Layout

Cascading Style Sheets (CSS)

NAVIGATION INSTRUCTIONS

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

By Ryan Stevenson. Guidebook #3 CSS

logo graphic will go here

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

Class 3 Page 1. Using DW tools to learn CSS. Intro to Web Design using Dreamweaver (VBUS 010) Instructor: Robert Lee

door to my garden Simple CSS resulting in impressive, sophisticated visual effects

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

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

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

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

Responsive Web Design. From: Ethan Marcotte - Responsive Web Design 2011

Parashar Technologies HTML Lecture Notes-4

Transcription:

EXTRA CSS3. #4

Where to write CSS. There are 3 places you can write CSS. The best option is to write CSS is in a separate.css file. You then link that file to your HTML file in the head of your document: <link rel="stylesheet" href="css/screen.css"> You can also write CSS in the <head> of each HTML page. <style> p{ color:red; </style> Or the last resort is to write CSS inline within a HTML element. To do that you add an attribute to the opening tag: <p style="color:red;">this will be red</p> You can use all 3 variations simultaneously if you wish. You can also load mulitple external CSS files.

CSS syntax. There are 3 parts to a rule, the selector, the property and the value. selector p { property value color:red; The punctuation is very important. - Each selector is followed by a set of curly brackets. - Inside this a property is followed by a colon - and the value is followed by a semi-colon.

The Box Model. A block HTML element can consist of margins, borders, padding and the content. Margin Border Padding Content

The Box Model. Content The content of the HTML element, where text and images appear. Padding Clears an area around the content but inside the border. It will have the background style of the element. Margin Border Padding Content Border The border goes outside the content and padding. Margin Clears an area outside the border. It is transparent.

The Box Model. Working out Size There are 2 ways to calculate the size of an element. You can change this by using the CSS rule box-sizing:border-box; Margin Border Padding Content or the default is box-sizing:content-box;

The Box Model. With content-box, you set the width and height of the content area. To calculate the full size that element takes up, you must also add padding, borders and margins..box{ width:250px; padding:25px; margin:25px; border:5px solid #ff9900; 360px Margin Border Padding 25px 25px Content 25px 25px 5px 250px 5px

The Box Model. With border-box, the width and height you set include any padding,borders and the content area. To calculate the full size that element takes up you only add margins..box{ box-sizing:border-box; width:250px; padding:25px; margin:25px; border:5px solid #ff9900; 300px 250px Border Padding 25px 25px Content 25px 25px 5px 5px

Margin. Margin makes an empty area or spacing around an HTML element. The margin area is transparent. You can use px or % as the unit. h1{ margin:20px;

Margin. There are 2 shorthand versions of margin. The first allows you to write the 4 values in one line. The order is top, right bottom, left. h1{ margin:20px 15px 10px 5px; or margin:20px 15px;

Margin. You can use the value 'auto' for the left and right margins that allows you to center an element horizontally. You also need to set a width. h1{ margin:20px auto; width:400px;

Margin. You can also define one margin side at a time. h1{ margin-left:20px;

Padding. Padding makes an empty area or spacing around an HTML content but inside the border. The padding area will use the background style of the HTML element. You can use px or % as the unit. h1{ padding:20px;

Padding. Like margin, there are the same 2 shorthand versions of padding. The first allows you to write the 4 values in one line. Again the order is top, right bottom, left. h1{ padding:20px 15px 10px 5px; or padding:20px 15px;

Width. The default width of a block element is 100%. You can set a smaller width in CSS. h1{ width:250px;

Width. You can also set a max-width. This is useful for responsive websites and different screen sizes. The max-width rule below will allow the element to reach a maximum width of 450px. At smaller screen sizes, it will be 100% wide. p { max-width:450px;

Height. You can also set a height for an element. Generally setting a height is not advisable as you can have problems if the content doesn't fit in the space defined. p { height:450px;

Height. A compromise is to use min-height. The rule below will set the element to be at least 450px high but allow it to expand if the content inside is taller. p { min-height:450px;

Unpredictable. CSS can be quite an unpredictable language to use. Browsers can treat CSS rules differently. One way to help is to use a CSS browser reset file. A good one is normalize.css, you can copy the CSS code from https://necolas.github.io/normalize. css/ You can then save it as a separate CSS file or place it at the top of an existing CSS file. If you save it separately, then you need to link it from your HTML pages. Normalize.css makes browsers render all elements more consistently and in line with modern standards.

Unpredictable. Writing CSS layouts almost always involves trial and error and adjustments. There can be multiple ways to achieve a similar effect but one may work better than another in a certain scenario. Don't be afraid to try a method, undo and try another. Always remember to ensure your browser is loading the newest version of the stylesheet. You can use cmd+r on a mac or f5 on a pc.

Display mode. The display property allows you to define if and how an element is displayed. All HTML elements have a default display mode but you can overwrite them. The 4 main options are block, inline, inline-block and none. There is also a new mode called flex h1 = block (100% wide) p = block (100% wide) span = inline (auto width) a = inline (auto width) img = inline (auto width)

Display mode. A block-level element starts on a new line and takes up the full width available. An inline element does not start on a new line and only takes up as much width as necessary. h1 = block (100% wide) p = block (100% wide) span = inline (auto width) a = inline (auto width) img = inline (auto width)

Display mode. One example where you may change display mode is with an image. Adding margin, padding, widths or heights to inline elements can be unpredictable. img{ display:block; margin:20px;

Positioning. The position property allows you to take an element out of the flow of the page. The default position value is static. The other options are relative, absolute and fixed. Setting an absolute or fixed position takes that content out of the flow of the page and content that follows will fill in the gap left behind. One problem is that you can be left with overlapping content so care is needed to keep an accessible, usable design. If an element's position isn't static, you can then set it's location with the property top, left, right or bottom and a value.

Positioning. position:fixed; is used to set a position relative to the browser window. A fixed element will not move if a user scrolls their window. A common implementation of position:fixed; is for a sticky navigation or footer.

nav{ Positioning. position:fixed; width:100%; top:0; left:0;

Positioning. position:absolute; allows you to position an HTML element relative to another HTML element. Again it is taken out of the flow and other content fills the space. Instead of being positioned relative to the viewport, an element is positioned relative to the nearest positioned parent. A positioned parent is an element with position:relative; If no parent is positioned, the element will be positioned relative to the browser window. Unlike a fixed element, an absolute positioned element will move as the user scrolls.

Positioning..container{ width:600px; position:relative;.popout{ position:absolute; background:orange; bottom:0; right:0; width:300px; container popout

Positioning. <div class="container"> <p>pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante.</p> container <div class="absolute"> <p>pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante.</p> </div> popout </div>

Positioning. When elements are positioned absolute or fixed, they can overlap other elements. The z-index property is similar to the order of layers in Photoshop or Illustrator. It specifies which element should be placed in front or behind the others. The higher the z-index the higher that element will display. nav{.popout{ z-index:10; z-index:15;

Floating. In its simplest use, the float property can be used to wrap text around images. img { float: right; You can float an element to the left or to the right. Any content that follows will wrap around the element if possible. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante.

Floating. Floating also takes an element out of the flow of the page. By default the parent element of a floated element will disregard the height of the floated element. This can lead to problems. Pellentesque habitant morbi tristique senectus. If the content is not longer than the floated element, the height can be incorrect. There is a fix for this, generally called clearfix. A good fix is available at nicolasgallagher.com/microclearfix-hack/

Floating. Here is a simplfied version with a more elaborate class name..clearfix:before,.clearfix:after { content: " "; display: table;.clearfix:after { clear: both;.clearfix { *zoom: 1;

Floating. You can apply this clearfix in 2 ways. The more efficient way is to apply it to the parent element that contains the floated element. Pellentesque habitant morbi tristique senectus. <div class="clearfix"> <img src="images/cat.jpg"> <p> Pellentesque habitant morbi tristique senectus.</p> </div>

Floating. You can also create a HTML element with a class clearfix just to fix the float. The disadvantage with this method is that you are adding HTML elements that are solely required for layout. Pellentesque habitant morbi tristique senectus. <div> <img src="images/cat.jpg"> <p> Pellentesque habitant morbi tristique senectus.</p> <div class="clearfix"></div> </div>

Floating. Using the same principles and the clearfix, you can float divs to make layouts..col{ width:33%; float:left; Pellentesque habitant morbi tristique senectus. Pellentesque habitant morbi tristique senectus. Pellentesque habitant morbi tristique senectus.

Floating. <div class="clearfix"> <div class="col"> <p> Pellentesque habitant morbi tristique senectus.</p> </div> <div class="col"> <p> Pellentesque habitant morbi tristique senectus.</p> </div> <div class="col"> <p> Pellentesque habitant morbi tristique senectus.</p> </div> </div> Pellentesque habitant morbi tristique senectus. Pellentesque habitant morbi tristique senectus. Pellentesque habitant morbi tristique senectus.

Pellentesque habitant morbi tristique senectus. Pellentesque habitant morbi tristique senectus. Pellentesque habitant morbi tristique senectus. Flex There is a new display mode called flex designed for layouts. Read more at css-tricks.com/snippets/css/a-guideto-flexbox/.container{ display:flex;.container div{ flex-grow:1; <div class="container"> <div>...</div> <div>...</div> <div>...</div> </div>

Resposive CSS rules. You can write CSS rules for certain screen sizes. These are generally split by breakpoints that suit certain screen types, e.g. tablet, smartphone, laptop/desktop and bigger monitors. You write CSS rules as before. This difference is you wrap the Screen size rules with another set of curly brackets so the rules become nested. @media screen and (max-width: 480px) { p{ font-size:11px;.container{ padding:15px;

For the next class. Using the same HTML content, create 3 visually different versions an About page using just CSS. http://www.csszengarden.com demonstrates this principle. The HTML content is at ixdncad.com under class #4 The only HTML changes you can make are: - Path to the CSS files in the head - Path and alt attributes for the 2 images - The text in the <h1></h1> and <title></title> Tags Use whatever CSS you like: remember child parent selectors.main p{ The 3 pages should represent: - An architectural/design led consultancy e.g. http://dmvf.ie - A governmental body/department e.g. https://www.revenue.ie - A drink/food company e.g. http://skoff.ie