CONTROLLING SIZES OF IMAGES USING CSS img.large { width: 500px; height: 500px;} img.medium { width: 250px; height: 250px;} img.small { width:

Slides:



Advertisements
Similar presentations
Ideas to Layout Beginning web layout using Cascading Style Sheets (CSS). Basic ideas, practices, tools and resources for designing a tableless web site.
Advertisements

1 Cascading Style Sheets Continued Different kinds of selectors in a style sheet –Simple- Pseudo-Class –Contextual- Pseudo-Element –Class Image Styles.
CSS Layout Crash Course An Advance CSS Tutorial. Inline vs. Block Many HTML elements have a default display setting of Block. Block elements take up the.
Chapter 6 More CSS Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
Part 5 Introduction to CSS. CSS Display - Block and Inline Elements A block element is an element that takes up the full width available, and has a line.
Principles of Web Design 5 th Edition Chapter Nine Site Navigation.
SM5312 week 11: CSS Menus & Navigation Bars1 An Introduction to Cascading Style Sheets CSS Menus and Navigation Bars Nick Foxall.
Advance CSS (Menu and Layout) Miftahul Huda. CSS Navigation MENU It's truly remarkable what can be achieved through CSS, especially with navigation menus.
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.
CSS(Cascading Style Sheets )
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
Diliev.com & pLOVEdiv.com  DIliev.com.
กระบวนวิชา CSS. What is CSS? CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to.
CSS normally control the html elements. Three Ways to Insert CSS There are three ways of inserting a style sheet: External style sheet Internal style.
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.
TUTORIAL 4: CREATING PAGE LAYOUT WITH CSS Session 4.3.
IMAGES Controlling size of images in CSS Aligning images in CSS Adding background images.
INTRODUCTION TO HTML5 Styling with CSS3. Round Border Corners  You can modify any element that supports the border property and render rounded borders.
Web Foundations TUESDAY, OCTOBER 22, 2013 LECTURE 16: WEB IMAGES.
INTRODUCTORY Tutorial 4 Exploring Graphic Elements and Images.
CSS Class 2 -Add margins to elements on a page. -Set width and height of elements. - CSS shorthand properties for box model. -Style links. -Style tables.
Week 8 – Part 2 Page Layout Basics Key Concepts 1.
Layout with Styles Castro Chapter 11. Tables vs. CSS You can produce “liquid layouts” (layouts that stretch as the browser is resized) using tables or.
>> CSS Layouts. Recall Properties of Box – Border (style, width, color) – Padding – Margin – Display – Background – Dimension Welcome Padding Area Border.
CSS.
Laying out Elements with CSS
>> Navigation and Layouts in CSS
Cascading Style Sheets Boxes
Cascading Style Sheets™ (CSS)
( Cascading style sheet )
Google fonts CSS box model
Advanced CSS & CSS3.
>> The “Box” Model
Advanced CSS BIS1523 – Lecture 20.
Box model.
Web Systems & Technologies
BOX DIMENSIONS width, height div { height: 300px; width: 400px; background-color: #ee3e80;} p { height: 75%; width: 75%; background-color:
>> CSS Layouts.
Chapter 7 Page Layout Basics Key Concepts
CSS.
IS333: MULTI-TIER APPLICATION DEVELOPMENT
Chapter 6 More CSS Basics Key Concepts
Cascading Style Sheets - Building a stylesheet
Basics of Web Design Chapter 7 Page Layout Basics Key Concepts
Cascading Style Sheets
Basics of Web Design Chapter 6 More CSS Basics Key Concepts
Fixed Positioning.
CSS Borders and Margins.
CSS Box Model.
MORE Cascading Style Sheets (The Positioning Model)
Box model, spacing, borders, backgrounds
Basics of Web Design Chapter 6 More CSS Basics Key Concepts
CSS and Box Model.
Basics of Web Design Chapter 6 More CSS Basics Key Concepts
Cascading Style Sheets™ (CSS)
How to use the CSS box model for spacing, borders, and backgrounds
CSS and Class Tools.
CSS Boxes CS 1150 Fall 2016.
Cascading Style Sheets - Building a stylesheet
CS3220 Web and Internet Programming More CSS
Cascading Style Sheets
Web Client Side Technologies Raneem Qaddoura
CS3220 Web and Internet Programming More CSS
CSc 337 Lecture 5: Grid layout.
Cascading Style Sheets™ (CSS)
CS3220 Web and Internet Programming More CSS
Presentation transcript:

CONTROLLING SIZES OF IMAGES USING CSS img.large { width: 500px; height: 500px;} img.medium { width: 250px; height: 250px;} img.small { width: 100px; height: 100px;}

CONTROLLING SIZES OF IMAGES USING CSS img.large { width: 500px; height: 500px;} img.medium { width: 250px; height: 250px;} img.small { width: 100px; height: 100px;}

CONTROLLING SIZES OF IMAGES USING CSS img.large { width: 500px; height: 500px;} img.medium { width: 250px; height: 250px;} img.small { width: 100px; height: 100px;}

CONTROLLING SIZES OF IMAGES USING CSS img.large { width: 500px; height: 500px;} img.medium { width: 250px; height: 250px;} img.small { width: 100px; height: 100px;}

CONTROLLING SIZES OF IMAGES USING CSS img.large { width: 500px; height: 500px;} img.medium { width: 250px; height: 250px;} img.small { width: 100px; height: 100px;}

CONTROLLING SIZES OF IMAGES USING CSS img.large { width: 500px; height: 500px;} img.medium { width: 250px; height: 250px;} img.small { width: 100px; height: 100px;}

CONTROLLING SIZES OF IMAGES USING CSS img.large { width: 500px; height: 500px;} img.medium { width: 250px; height: 250px;} img.small { width: 100px; height: 100px;}

ALIGNING IMAGES USING CSS img.align: left { float: left; margin-right: 10px;} img.align-right { float: right; margin-left: 10px;} Note: It's important to create a gap between text and pictures.

ALIGNING IMAGES USING CSS img.align: left { float: left; margin-right: 10px;} img.align-right { float: right; margin-left: 10px;}

ALIGNING IMAGES USING CSS img.align: left { float: left; margin-right: 10px;} img.align-right { float: right; margin-left: 10px;}

ALIGNING IMAGES USING CSS img.align: left { float: left; margin-right: 10px;} img.align-right { float: right; margin-left: 10px;}

ALIGNING IMAGES USING CSS img.align: left { float: left; margin-right: 10px;} img.align-right { float: right; margin-left: 10px;}

ALIGNING IMAGES USING CSS img.align: left { float: left; margin-right: 10px;} img.align-right { float: right; margin-left: 10px;}

ALIGNING IMAGES USING CSS img.align: left { float: left; margin-right: 10px;} img.align-right { float: right; margin-left: 10px;}

CENTERING IMAGES USING CSS img.align-center { display: block; margin: 0px auto;} img.medium { width: 250px; height: 250px;}

CENTERING IMAGES USING CSS img.align-center { display: block; margin: 0px auto;} img.medium { width: 250px; height: 250px;} Display property needs to be added here to center the image.

CENTERING IMAGES USING CSS img.align-center { display: block; margin: 0px auto;} img.medium { width: 250px; height: 250px;} Margin property needs to be auto for left and right margins.

BACKGROUND IMAGES background-image p { background-image: url("images/ pattern.gif");}

BACKGROUND IMAGES background-image p { background-image: url("images/ pattern.gif");}

REPEATING IMAGES background-repeat body { background-image: url("images/ header.gif"); background-repeat: repeat-x;} Possible values: repeat-x; repeat-y; no-repeat;

REPEATING IMAGES background-repeat body { background-image: url("images/ header.gif"); background-repeat: repeat-x;} Possible values: repeat-x; repeat-y; no-repeat;

FIXED BACKGROUND IMAGES background-attachment body { background-image: url("images/ tulip.gif"); background-repeat: no-repeat; background-attachment: fixed;} Possible values: fixed, scroll

FIXED BACKGROUND IMAGES background-attachment body { background-image: url("images/ tulip.gif"); background-repeat: no-repeat; background-attachment: fixed;} Possible values: fixed, scroll

BACKGROUND POSITION background-position body { background-image: url("images/ tulip.gif"); background-repeat: no-repeat; background-position: center top;} body { background-image: url("images/ tulip.gif"); background-repeat: no-repeat; background-position: 50% 50%;}

BACKGROUND POSITION background-position body { background-image: url("images/ tulip.gif"); background-repeat: no-repeat; background-position: center top;} body { background-image: url("images/ tulip.gif"); background-repeat: no-repeat; background-position: 50% 50%;}

BACKGROUND POSITION background-position body { background-image: url("images/ tulip.gif"); background-repeat: no-repeat; background-position: center top;} body { background-image: url("images/ tulip.gif"); background-repeat: no-repeat; background-position: 50% 50%;}

SHORTHAND background body { background: #ffffff url("images/ tulip.gif") no-repeat top right;} Need to specify in following order (but any can be missed) 1: background-color2: background-image3: background-repeatNOTE: background-attachment would be next (not used here) 5: background-position

SHORTHAND background body { background: #ffffff url("images/ tulip.gif") no-repeat top right;} Need to specify in following order (but any can be missed) 1: background-color2: background-image3: background-repeatNOTE: background-attachment would be next (not used here) 5: background-position

SHORTHAND background body { background: #ffffff url("images/ tulip.gif") no-repeat top right;} Need to specify in following order (but any can be missed) 1: background-color2: background-image3: background-repeatNOTE: background-attachment would be next (not used here) 5: background-position

SHORTHAND background body { background: #ffffff url("images/ tulip.gif") no-repeat top right;} Need to specify in following order (but any can be missed) 1: background-color2: background-image3: background-repeatNOTE: background-attachment would be next (not used here) 5: background-position

SHORTHAND background body { background: #ffffff url("images/ tulip.gif") no-repeat top right;} Need to specify in following order (but any can be missed) 1: background-color2: background-image3: background-repeatNOTE: background-attachment would be next (not used here) 5: background-position

IMAGE ROLLOVERS & SPRITES Explain: Single image reduces number of calls to server = faster loading

IMAGE ROLLOVERS & SPRITES a.button { height: 36px; background-image: url("images/button- sprite.jpg"); text-indent: -9999px; display: inline-block;} a#add-to-basket { width: 174px; background-position: 0px 0px;} a#framing-options { width: 210px; background-position: -175px 0px;}

IMAGE ROLLOVERS & SPRITES a.button { height: 36px; background-image: url("images/button- sprite.jpg"); text-indent: -9999px; display: inline-block;} a#add-to-basket { width: 174px; background-position: 0px 0px;} a#framing-options { width: 210px; background-position: -175px 0px;} The same background image is used for all links with a class of "button".

IMAGE ROLLOVERS & SPRITES a.button { height: 36px; background-image: url("images/button- sprite.jpg"); text-indent: -9999px; display: inline-block;} a#add-to-basket { width: 174px; background-position: 0px 0px;} a#framing-options { width: 210px; background-position: -175px 0px;} This code allows the dimensions to work.

IMAGE ROLLOVERS & SPRITES a.button { height: 36px; background-image: url("images/button- sprite.jpg"); text-indent: -9999px; display: inline-block;} a#add-to-basket { width: 174px; background-position: 0px 0px;} a#framing-options { width: 210px; background-position: -175px 0px;} Here you can see they display different parts of the image.

IMAGE ROLLOVERS & SPRITES a.button { height: 36px; background-image: url("images/button- sprite.jpg"); text-indent: -9999px; display: inline-block;} a#add-to-basket { width: 174px; background-position: 0px 0px;} a#framing-options { width: 210px; background-position: -175px 0px;} All buttons are the same height.

IMAGE ROLLOVERS & SPRITES a.button { height: 36px; background-image: url("images/button- sprite.jpg"); text-indent: -9999px; display: inline-block;} a#add-to-basket { width: 174px; background-position: 0px 0px;} a#framing-options { width: 210px; background-position: -175px 0px;} The width property for specific links varies for each button.

IMAGE ROLLOVERS & SPRITES a#add-to-basket:hover { background-position: 0px -40px;} a#framing-options:hover { background-position: -175px -40px;} a#add-to-basket:active { background-position: 0px -80px;} a#framing-options:active { background-position: -175px -80px;}

IMAGE ROLLOVERS & SPRITES a#add-to-basket:hover { background-position: 0px -40px;} a#framing-options:hover { background-position: -175px -40px;} a#add-to-basket:active { background-position: 0px -80px;} a#framing-options:active { background-position: -175px -80px;} Hover states move the background position on mouseover.

IMAGE ROLLOVERS & SPRITES a#add-to-basket:hover { background-position: 0px -40px;} a#framing-options:hover { background-position: -175px -40px;} a#add-to-basket:active { background-position: 0px -80px;} a#framing-options:active { background-position: -175px -80px;} Active states move the background position to show clicking.

CSS3: GRADIENTS background-image #gradient { /* fallback color */ background-color: #66cccc; /* fallback image */ background-image:url("images/fallback -image.png"); /* Firefox 3.6+ */ background-image: -moz-linear-gradient(#336666, #66cccc); CSS3 gradients do not work with all browsers.

CSS3: GRADIENTS background-image #gradient { /* fallback color */ background-color: #66cccc; /* fallback image */ background-image:url("images/fallback -image.png"); /* Firefox 3.6+ */ background-image: -moz-linear-gradient(#336666, #66cccc); This is the color that will appear if the browser does not support CSS3 gradients.

CSS3: GRADIENTS background-image #gradient { /* fallback color */ background-color: #66cccc; /* fallback image */ background-image:url("images/fallback -image.png"); /* Firefox 3.6+ */ background-image: -moz-linear-gradient(#336666, #66cccc); The fallback image contains its own gradient.

CSS3: GRADIENTS background-image #gradient { /* fallback color */ background-color: #66cccc; /* fallback image */ background-image:url("images/fallback -image.png"); /* Firefox 3.6+ */ background-image: -moz-linear-gradient(#336666, #66cccc); The Firefox syntax includes a "from color" and a "to color" in parentheses.

CSS3: GRADIENTS background-image /* Safari 4+, Chrome 1+ */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#66cccc), to(#336666)); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient(#336666,#66cccc); /* Opera 11.10+ */ background-image: -o-linear-gradient(#336666, #66cccc); }

CSS3: GRADIENTS background-image /* Safari 4+, Chrome 1+ */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#66cccc), to(#336666)); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient(#336666,#66cccc); /* Opera 11.10+ */ background-image: -o-linear-gradient(#336666, #66cccc); }

CSS3: GRADIENTS background-image /* Safari 4+, Chrome 1+ */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#66cccc), to(#336666)); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient(#336666,#66cccc); /* Opera 11.10+ */ background-image: -o-linear-gradient(#336666, #66cccc); }

CSS3: GRADIENTS background-image /* Safari 4+, Chrome 1+ */ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#66cccc), to(#336666)); /* Safari 5.1+, Chrome 10+ */ background-image: -webkit-linear-gradient(#336666,#66cccc); /* Opera 11.10+ */ background-image: -o-linear-gradient(#336666, #66cccc); }

CONTRAST OF BACKGROUND IMAGES HIGH CONTRAST LOW CONTRAST SCREEN Shows how contrast between images and overlaid text affects readability. unreadable readable readable

SUMMARY You can specify the dimensions of images using CSS. This is very helpful when you use the same sized images on several pages of your site. Clicks: Load individual bullets

Images can be aligned both horizontally and vertically using CSS. SUMMARY Images can be aligned both horizontally and vertically using CSS. Clicks: Load individual bullets

You can use a background image behind the box created by any element SUMMARY You can use a background image behind the box created by any element on a page. Clicks: Load individual bullets

SUMMARY Background images can appear just once or be repeated across the background of the box. Clicks: Load individual bullets

SUMMARY You can create image rollover effects by moving the background position of an image. Clicks: Load individual bullets

To reduce the number of images your browser has SUMMARY To reduce the number of images your browser has to load, you can create image sprites. Clicks: Load individual bullets