Cascading Style Sheets Chapters 5-6 Color and Background Controls Border and Margin Controls.

Slides:



Advertisements
Similar presentations
1 Cascading Style Sheets Continued Different kinds of selectors in a style sheet –Simple- Pseudo-Class –Contextual- Pseudo-Element –Class Image Styles.
Advertisements

Client-Side Internet and Web Programming
Cascading Style Sheets Color and Background Controls Border and Margin Controls (Boxes)
9-May-15 More CSS. 2 A different emphasis CSS is the same for XML as it is for HTML and XHTML, but-- XML contains no display information If you want your.
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.
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.
Tutorial 4: Creating page layout with css
Tutorial 5 Working with the Box Model. XP Objectives Understand the box model Create padding, margins, and borders Wrap text around an image Float a block-level.
CSS: Class 1 Background Images, Controlling Position of Background Images, Add Padding to Page Elements, Add Borders to Elements on a Page.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 6 - Cascading Style Sheets™ (CSS) Outline 6.1 Introduction 6.2 Inline Styles 6.3 Embedded Style.
1 Lesson Style Sheets Box Model Content (text,image,table) Margin Padding Border Box.
TUTORIAL 4: CREATING PAGE LAYOUT WITH CSS Session 4.3.
Cascading Style Sheets Part 3 Fall, 2007 Modified by Linda Kenney Nov. 12, 2007.
CSS Box Model margin border padding content 23. Box Model Properties PropertyValid valuesExample border-widththin, medium, thick, numberborder-width:
An Introduction to Cascading Style Sheets CSS Layout, and the CSS Box Model Nick Foxall SM5312 week 9: CSS Layout.
Style sheets can also affect the BODY. style4.css BODY {BACKGROUND-COLOR : white} H1 {COLOR : red; FONT-SIZE : 50; FONT-FAMILY : arial} H2 {COLOR : green}
Style sheets can also affect the body. style4.css body {background-color : white} h1 {color : red; font-size : 50; font-family : arial} h2 {color : green}
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.
CSS to Know And this is just the beginning. What to What?  Tags = regular HTML  Ids = #id, only one hashtag per page  Class =.class, many as you want.
Selectors thru Borders. CSS – Cascading Style Sheets – is a way to style HTML HTML is the content base of a web page CSS provides the presentation qualities.
Cascading Style Sheets 1 Color and Backgrounds. Cascading Style Sheets 2 Color and Backgrounds Computer color basics Expression of color values using.
CSS Margins. The Margin properties define the space around elements. It is possible to use negative values to overlap content. The top, right, bottom,
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.
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
Cascading Style Sheets CSS. CSS - Structure Declaration block Property: identifies what to change Value: how to change it Selector – example h1{ font-size:
The Missing Manual MARGINS, PADDING, & BORDERS—CHAPTER 7.
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
Chapter 12 Cascading Style Sheets: Part II The Web Warrior Guide to Web Design Technologies.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
CSS Border.
Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border 
Adding Graphics to Web Pages. CSS does not have any properties specifically aimed at formatting images Use properties you have already learned, i.e.,
COMP213 – Web Interface Design
LITTLE BOXES Controlling size of boxes Box model for borders, margin and padding Displaying and hiding boxes.
 2008 Pearson Education, Inc. All rights reserved Cascading Style Sheets™ (CSS)
Chcslonline.org Text –wrapping around Images. chcslonline.org To wrap text around an image, lets set up a style in our style sheet. open a new notepad.
INTRODUCTORY Tutorial 4 Exploring Graphic Elements and Images.
Web Foundations THURSDAY, OCTOBER 3, 2013 LECTURE 6: CSS CONTINUED.
>> The “Box” Model. Pre-requisite Create a new project in Netbeans called Week5 Create a new html file and name it box.html Create a new css file and.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 6 - Cascading Style Sheets™ (CSS) Outline 6.1 Introduction 6.2 Inline Styles 6.3 Embedded Style.
 Cascading Style Sheets (CSS) ◦ Used to specify the presentation of elements separately from the structure of the document.  Inline style ◦ declare.
1 CS428 Web Engineering Lecture 08 Border, Margin, Padding … (CSS - III)
CSS Layout Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  CSS Box Model  CSS properties for border  CSS properties for.
CIS234A Lecture 5 Instructor Greg D’Andrea. Font Styles Review Font-Family: generic family, font family Font-Size: em, pt, px, %, mm, cm, in Font-Style:
3.2 Cascading Style Sheets. 2 Positioning Elements Normally, elements are laid out on the page in the order that they are defined in the XHTML document.
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
Doncho Minkov Telerik School Academy schoolacademy.telerik.com Technical Trainer
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.
CSS Table Styling. Up to this point, as we haven't applied any CSS styling to our tables, our example tables have not been too pleasing to the eye. CSS.
CIS 228 The Internet 10/18/11 Grouping XHTML. CSS Selectors Rule: selector-group { property-declaration* } Selector-group: selector *, Selector: simple-selector.
Tutorial #5 Working with the Box Model. Tutorial #4 Review - CSS Create a homework page Final Project Discussion Exam on Blackboard Styling Lists (List-style-type,
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 & CSS Contents: the different ways we can use to apply CSS to The HTML documents CSS Colors and Background CSS Fonts CSS Text CSS box model: padding,
CSS. What does it stand for? ___________________.
CSS. What does it stand for? Cascading Style Sheet.
Cascading Style Sheets Boxes
( Cascading style sheet )
>> The “Box” Model
BOX DIMENSIONS width, height div { height: 300px; width: 400px; background-color: #ee3e80;} p { height: 75%; width: 75%; background-color:
Cascading Style Sheets
The Internet 10/13/11 The Box Model
CSS Borders and Margins.
Second CSS Lecture Applications to XML
Cascading Style Sheets
CSS Boxes CS 1150 Fall 2016.
Cascading Style Sheets™ (CSS)
Presentation transcript:

Cascading Style Sheets Chapters 5-6 Color and Background Controls Border and Margin Controls

Setting a Foreground Color Keyword is color: (for foreground, primarily for text, borders; NOT font-color:) May be specified as a hex value (#123456;) shorthand (#abc;) word (red;) or rgb (rgb(51, 102, 51); OR rgb(20%, 40%, 20%);) Watch for color changes when assigning color to several tags in a window. Watch border colors for elements. The border-color property will override the color tag on the border color.

Color and Background Controls background- – color: #abc; defines the color of the background. Should specify when color: is specified. Can be background-color: transparent; – image: url(alice.gif); defines a url image to be put in the background – repeat: no-repeat; defines where the image should repeat and how. See next slide – attachment: fixed; defines if the image can be scroll with the text or if is fixed in its position – position: -10px 10px; defines where the image should be positioned (left, then top) –Can combine any set of these background: white url(alice.gif) no-repeat fixed right top; Note examples that style form buttons (p. 155)

repeat options repeat –Repeat the graphic throughout the background. repeat-x –Only repeat the graphic horizontally repeat-y –Only repeat the graphic vertically no-repeat –Don’t repeat the graphic

attachment options fixed – Instructs the browser not to scroll the background. scroll –Instructs the browser to scroll the graphic.

position options length value –Can be a single or double set of values –First value is the distance from the left edge of the parent element. Positive means to the right, negative to the left. Units are pixels, or ems. –Second value specifies the position from the top edge of the parent. percentage –Defines the size proportional to the parent’s element size. First value is the horizontal position, second value is the vertical position. keywords –Top, bottom, left, right, center background-position: top center;

Box Properties The elements in a “box” have very specific roles. Margin defines the space between the border of the element and other elements in the window. Border is the rule (line) that surrounds the element. Padding is the space between the border and the content of the element. See the graphic on the next slide.

Borders/Margins Child Element Content Padding Border Margin

Box model problems MOSE, IE7/IE6 if DTD=Strict get it right. If: width:100px; border: 5px solid red; padding: 10px; Then the box you see will be 130px wide (why?) In other (older) browsers, the box you see will be 100px wide. So, ignore it, use Strict DTD or (better)

Display options display:block; Useful for separating box from other content and for full box model properties display:inline; display:none; Useful for print style sheets. No space left where element was

Margins margins –You can set the size for all margins for an element. – margin-top, margin-right, margin-bottom, margin-left. –Each may be set separately.

value lists –Two values margin: 10px 20px; First is top/bottom, second is the left/right –Three values margin: 5px 10px 20px; First is top, second is left/right, third is bottom. –Four margin: 5px 10px 15px 20px; First is top, second is right, third is bottom, fourth is left. Use a clockwise rotation—starting from top (or TRBL). –You may also specify each individually. Margin-top: -10px; Also consider margin: 0px auto;

Border options border-width –Specifies the width of the line display –Options—a length (px) or keyword thin, medium, thick border-style –Specifies the type of line –Options—none, dotted, dashed, solid, double, groove, ridge, inset, outset border-color –Specifies the color to display Each border may be specified uniquely with separate specs for each line (border-left, right, top, bottom) Shorthand is at least width, style color border: 5px solid red; Rounded corners, outline: new for Mozilla only.

Padding Used to set the padding between element’s content and border Set of four values—set clockwise –Top, right-side, bottom, left-side –To see the results of padding, you need turn on the borders. Setting padding and margins appears to be the same—remember margins are relative to the parent element and the current element, padding is relative to the current element and its border.

Width, height Can be powerful Use px, em or % combine with overflow: auto; (or scroll;) Consider max-width: or max-height min-width: or min-height for elastic liquid/layouts (MOSE or IE7+)