Cascading Style Sheets

Slides:



Advertisements
Similar presentations
Web Engineering 1 Ishaq Khan Shinwari MCS City University Peshawar.
Advertisements

1 Cascading Style Sheets Continued Different kinds of selectors in a style sheet –Simple- Pseudo-Class –Contextual- Pseudo-Element –Class Image Styles.
Client-Side Internet and Web Programming
With CSS, a color is most often specified by: a HEX value - like "#ff0000" an RGB value - like "rgb(255,0,0)" a color name - like "red“ Example h1.
Cascading Style Sheets Color and Background Controls Border and Margin Controls (Boxes)
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.
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.
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}
Cascading Style Sheets 1 Color and Backgrounds. Cascading Style Sheets 2 Color and Backgrounds Computer color basics Expression of color values using.
Cascading Style Sheets CSS. CSS - Structure Declaration block Property: identifies what to change Value: how to change it Selector – example h1{ font-size:
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
CSS Border.
INTRODUCTORY Tutorial 4 Exploring Graphic Elements and Images.
Cascading Style Sheets Chapters 5-6 Color and Background Controls Border and Margin Controls.
>> 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.
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.
Tutorial 4 Creating Page Layouts with CSS
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.
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,
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.
WebD Introduction to CSS By Manik Rastogi.
CSS.
Chapter 6 - Cascading Style Sheets™ (CSS)
Cascading Style Sheets Boxes
CSS Layouts CH 13.
Cascading Style Sheets™ (CSS)
( Cascading style sheet )
CSS Layouts: Grouping Elements
>> The “Box” Model
Cascading Style Sheets (Formatting)
CSS3 Cascading Style Sheet
Cascading Style Sheets (Layout)
Web Systems & Technologies
BOX DIMENSIONS width, height div { height: 300px; width: 400px; background-color: #ee3e80;} p { height: 75%; width: 75%; background-color:
CSS Applications to XML 19-Sep-18.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Chapter 6 More CSS Basics Key Concepts
Objectives Create a reset style sheet Explore page layout designs
Creating Layouts Using CSS
Basics of Web Design Chapter 6 More CSS Basics Key Concepts
The Internet 10/13/11 The Box Model
CSS Borders and Margins.
Second CSS Lecture Applications to XML
MORE Cascading Style Sheets (The Positioning Model)
HTML5 Level I Session III
HTML5 Level I Session III
Box model, spacing, borders, backgrounds
Cascading Style Sheets
Basics of Web Design Chapter 6 More CSS Basics Key Concepts
More CSS Page layout Boriana Koleva Room: C54
SEEM4570 Tutorial 3: CSS + CSS3.0
How to use the CSS box model for spacing, borders, and backgrounds
More CSS 22-Feb-19.
The Box Model.
CSS Boxes CS 1150 Fall 2016.
CS3220 Web and Internet Programming More CSS
Cascading Style Sheets
CSS Applications to XML 20-May-19.
CS3220 Web and Internet Programming More CSS
CSc 337 Lecture 5: Grid layout.
CSS Applications to XML 3-Jul-19.
ITI 133: HTML5 Desktop and Mobile Level I
Cascading Style Sheets™ (CSS)
CS3220 Web and Internet Programming More CSS
Presentation transcript:

Cascading Style Sheets Color and Background Controls Border and Margin Controls (Boxes)

Setting a Foreground Color Keyword is color: (for foreground, primarily for text, borders; there is no font-color: property) May be specified as a hex value (#123456;) shorthand (#abc;) word (red;) rgb (rgb(51, 102, 51); OR rgb(20%, 40%, 20%);), hsl (180, 50%, 75%), rgba(51,102,51, .7), hsla(180,50%,75%, .3) Watch border colors for elements. The border-color property will override the color tag on the border color.

Color and Background Controls color: #abc; defines the color of the background . Should specify when color: is specified. Can be background-color: transparent; Shorthand is background: #abc; image: url(alice.gif); defines a url image to be put in the background. Use for all presentational graphics 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(fred.gif) no-repeat fixed right top;

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

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

background-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 Border Content Child Element Margin Padding

Box model problems MOSe, 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. This was an IE 5 and earlier problem. So, ignore it, use Strict DTD or (better) <!-- [if lte IE6]> <link href="ie5.css"><![endif]--> Or in CSS3, use box-sizing: border-box;

Display options display: block; Useful for separating box from other content and for full box model properties. Vertical list of links <a> is inline by default. 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 centering trick for container <div> is 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 since MOSe and IE9.

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 to 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