35
Unit I Applying Advanced Styling CSS

Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Embed Size (px)

Citation preview

Page 1: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Unit I

Applying Advanced

Styling

CSS

Page 2: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

CSS3 can style many aspects that in the past required integration of images

New features are not supported by all browsers.

Should try to make Web site usable for users with the least-featured browser.

Page 3: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all
Page 4: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Two sides to a coin

Progressive enhancement

Graceful degradation

It is a matter of direction.

Page 5: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Graceful degradation: ensuring that when site is viewed in browsers that don’t support advanced features, Web page elements should still be displayed in a usable way.

Page 6: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Graceful degradation: ”The practice of building your web functionality so that it provides a certain level of user experience in more modern browsers, but it will also degrade gracefully to a lower level of user experience in older browsers. This lower level is not as nice to use for your site visitors, but it does still provide them with the basic functionality that they came to your site to use; things do not break for them.”

ww3.org

Page 7: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Graceful degradationoAppearance and usability of Web site

don’t depend on advanced featureso Example: specifying alternative text for

an image, in case the image cannot be displayed

Page 8: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Progressive enhancement: additional features are used as enhancements only for browsers that can render them

oMain content and capabilities available for least-featured browser

oAdvanced features not crucial to the layout of the Web site

Page 9: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Progressive enhancement enables us to establish a solid baseline of cross-browser support and then enhance the design with advanced CSS features for supportive browsers.

Page 10: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

• Graceful degradation starts from the status quo of complexity and tries to fix for the lesser experience whereas progressive enhancement starts from a very basic, working example and allows for constant extension for future environments.

• Degrading gracefully means looking back whereas enhancing progressively means looking forward whilst keeping your feet on firm ground.

Page 11: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Shims or patches:

Scripts written specifically to bridge the gap between browsers with reduced feature sets and more fully featured browsers

oAvailable for use by anyone free of charge

o Some address a single issueo Some tools package shims in a library of

scripts• Examples: Modernizr, PIE

Page 12: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Pseudo-element: selectors that enable you to isolate a portion of a larger element for styling

oPreceded by colon (:) in older browsers or by double colon (::) in newer ones• Double colon distinguishes pseudo-

element from pseudo-class

A pseudo-class filters existing elements.a:link means all <a>s that are :link.

A pseudo-element is a new fake element.div::after means non-existing elements after <div>s.

Page 13: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Drop cap: First letter is enlarged and drops below the first line of text

• Can be created using :first-letter• Must format surrounding text to flow

around – use the float property

Page 14: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

:first-line pseudo-element applied to paragraph

Page 15: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

:before and :after pseudo-elements: allow you to insert content into Web page using style rules

o Typically used for repeated text or pictureso Must specify value for the content property

• Can be text or path to an image

http://krasimirtsonev.com/blog/article/CSS-before-and-after-pseudo-elements-in-practice

Page 16: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

:before pseudo-element code and result

Page 17: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

What is the difference between opacity and transparency?

Opacity is just the opposite of transparency. If something is 100% opaque, then it's 0% transparent. If it's 75% transparent, then it's 25% opaque. 

Page 18: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

OpacityColor can be specified in hexadecimal, rgb, and hsl – hue saturation light.

Alpha channel: fourth color value representing the opacity

oWorks for rgb and hsl, known as rgba and hsla

oReceives decimal between 0 (fully opaque) and 1 (fully transparent).

http://deepubalan.com/blog/2010/03/29/rgba-vs-opacity-

the-difference-explained/

Page 19: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Opacity – Graceful degradation

oMany browsers do not support the rgba property.

oUsing the concept of graceful degradation - use this along with rgb

Page 20: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

rgba code and resulting partially transparent element

RGBRGBA

Page 21: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Creating rounded corners is possible using the CSS3 border-radius property

Page 22: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

In past, required overlay of image files simulating the rounded edge

Page 23: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

border-radius property• Receives value in pixels• Larger value results in deeper curves• Can use individual property for each

corner• Requires –moz and –webkit prefixes to

work with some browsers

Page 24: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Code for rounded footer corners and resulting element

Page 25: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all
Page 26: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

border-radius: 1em;

border-radius-topright: 2em;border-radius-topleft: 2em;

border-radius: 2em 0;

border-radius: 3em 1em;

border-radius: 1em;

border-radius-topright: 2em;border-radius-topleft: 2em;

border-radius: 2em 0;

border-radius: 3em 1em;

Page 27: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Text shadow: creates the appearance of a shadow on a surface behind the text

o In past, required using image manipulation software and linking to resulting graphic

In CSS3, use text-shadow property o Takes four values: horizontal offset,

vertical offset, blur, and shadow color

Page 28: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Values for the text shadow property and resulting graphic

text-shadow: 2px 3px 2px #000;

http://designshack.net/articles/css/12-fun-css-text-shadows-you-can-copy-and-paste/

Page 29: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Box shadow: creates the appearance of a shadow on an entire unit of page content.

o Takes four values: horizontal offset, vertical offset, blur, and shadow color

oHas –webkit and –moz variants

http://www.w3schools.com/css/css3_shadows.asp Examples of both text and box shadow

Page 30: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Examples

Page 31: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Code for box-shadow

Page 32: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Modernizr: free script library for enabling alternative code in order to support graceful degradation

o Linked to a Web page and tests each user’s browser to detect supported properties

oBased on results, generates set of CSS classes, which can be used by designer to write alternative code and make sure that only the suitable code is rendered

Page 33: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

Code incorporating Modernizr script

Page 34: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

So HTML5 and CSS3 are not that confusing when you have good teachers.

Page 35: Unit I Applying Advanced Styling CSS. CSS3 can style many aspects that in the past required integration of images New features are not supported by all

But wait there’s 2 more.