Download presentation
Presentation is loading. Please wait.
Published byHenry Ford Modified over 8 years ago
1
Advanced CSS
2
Display Hiding an element can be done in two ways display:none Element is hidden and will no longer take up space on the page Can be thought of as being removed from the DOM visibility:hidden Element is hidden but still takes up the same space Other elements on the page will behave as though the hidden element is still there It is just not visible on the page
3
Positioning CSS positioning allows you to position elements on a page Elements can be positioned using top, left, bottom and right but only if their position property is set first Four different positioning methods Static positioningposition: static; Fixed positioningposition:fixed; Relative positioningposition:relative; Absolute positioningposition:absolute;
4
CSS Positioning Static positioning This is the default positioning A static positioned element is always positioned according to the normal flow of the page Top, left, right and bottom properties have no effect Fixed positioning Element is positioned relative to the browser window It will not move even if the window is scrolled Elements are removed from the normal flow of the page All other elements behave as if the fixed element does not exist
5
CSS Positioning Relative Positioning A relative positioned element is positioned relative to its normal position The content of the relatively positioned element can be moved and overlap other elements The reserved space for the element is preserved in the normal flow of the document Absolute Positioning Absolutely positioned element are positioned relative to the first parent that has a position other than static They are removed from the normal flow of the document
6
CSS Positioning Excellent Tutorial for CSS Positioning http://www.barelyfitz.com/screencast/html- training/css/positioning/ http://www.barelyfitz.com/screencast/html- training/css/positioning/
7
CSS Floating Elements are floated horizontally, left or right A floated element will move as far to the left or right as its containing element will allow Elements after the floating element will flow around it Elements before the floating element will not be affected Several floating elements after each other will float next to each other
8
CSS Floating clear property is used to clear floats Syntax: #news { float: right; clear: both; } http://css-tricks.com/all-about-floats/ http://css-tricks.com/all-about-floats/
9
Pseudo class selectors Used to add special effects to some selectors Some pseudo selectors are newer features of CSS3 Syntax selector:pseudo-class {property:value;} Selector.class:pseudo-class {property:value;}
10
Anchor Selectors a:link {color:#FF0000;} /* unvisited link */ a:visited {color:#00FF00;} /* visited link */ a:hover {color:#FF00FF;} /* mouse over link */ a:active {color:#0000FF;} /* selected link */
11
:first-child selector :first-child pseudo class matches an element that is the first child of another element e.g. #content p:first-child { font-weight: italic; } This matches the first p tag that is a child of the enclosing tag with id=content
12
:before and :after Insert content before or after the specified selector Eg p:after { content:"- Remember this"; } Inserts the content after every element p:before { content:“A wise man once said: "; } Inserts the content before every element
13
CSS Pseduo selectors Extensive list of CSS Pseudo Selectors http://css-tricks.com/pseudo-class-selectors/
14
Attribute Selectors In addition to using class and id selectors for specifying css styles, you can use the attributes of elements HTML CSS [alt=Demo], img[alt=Demo] { border: 1px solid #0f0; } This will apply a green border to any tag that has an alt value of “Demo”
15
Other Examples of attribute selectors [name~=value] ~= is used to mean if the attribute contains a specified value even if the words are separated by spaces Expression [title~=hello] { color: blue} Matches [name*=value] *= selects elements that have attributes with a value containing the specified substring Expression [class*=large] { font-size: 30px;} Match
16
Other Examples of attribute selectors [name$=value] Selects elements that have attributes ending exactly with a given string Expression [class$=font] { color: red;} Match Warning [name!=value] Selects elements that do not have the specified attribute or do have the specified attribute but not with a certain value Expression [class!=font] { color: red;} Match Warning
17
Other Examples of attribute selectors [name^=value] Selects elements that have attributes beginning exactly with a given string Expression [class^=pretty] { border-color: blue;} Match [name|=value] Selects elements that have the specified attribute with a value equal to a given string or starting with a string followed by a hypen ( -) Expression [class|=space] {margin: 5px;} Match Warning
18
What is CSS3? Next evolution of CSS Allows developers to build cleaner pages, create better visual effects and all with pages loading faster than before Still a work in progress but the latest browsers have already implemented a large majority of the specification Specification is broken down in to a module based approach – it is so large that breaking it up into modules makes adoption by browsers easier Selectors module Colors and Backgrounds Positioning Visual Effects etc
19
Examples of new features of CSS3 More powerful selectors Text Effects and Layouts changes to hyphenation, whitespace and justification of text in documents Multi-Column layout Allows designers to display content in multiple columns with definitions such as column-gap, column-count and column-width Multiple backgrounds on a page Shading and curved borders and much more
20
CSS3 CSS Roadmap http://www.w3.org/TR/CSS/http://www.w3.org/TR/CSS/ New options allow styles to be used instead of traditional graphics for professional looking websites http://www.css3.info/preview/ http://www.css3.info/preview/ curved borders curved borders box shadows box shadows multiple backgrounds multiple backgrounds colors and opacity colors and opacity image opacity image opacity text effects text effects
21
References CSS Reference http://www.w3schools.com/cssref/default.asp http://www.w3schools.com/cssref/default.asp CSS Selector Reference http://www.w3schools.com/cssref/css_selectors.asp http://www.w3schools.com/cssref/css_selectors.asp CSS Web Safe Fonts http://www.w3schools.com/cssref/css_websafe_fonts.asp http://www.w3schools.com/cssref/css_websafe_fonts.asp CSS Colors and Web Safe Colors http://www.w3schools.com/cssref/css_colors.asp http://www.w3schools.com/cssref/css_colors.asp Color Scheme Designer http://colorschemedesigner.com http://colorschemedesigner.com
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.