User Tools

Site Tools


eg-146:lecture16

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
eg-146:lecture16 [2012/03/19 20:22] – [Case Study: Developing a Positioning Style Sheet] eechriseg-146:lecture16 [2012/03/19 20:52] – [Controlling Where Elements Float] eechris
Line 525: Line 525:
  * Examine the structure.  * Examine the structure.
  
-===== The CSS Reset ===== 
- 
-  * Common technique, ensures that design starts from a blank slate on all browsers 
  
 ===== The HTML5 display-role reset ===== ===== The HTML5 display-role reset =====
Line 533: Line 530:
   * For older browsers, ensures that new elements are set as blocks   * For older browsers, ensures that new elements are set as blocks
   * For IE browsers, we also need a JavaScript HTML5 fix (see the HTML5)   * For IE browsers, we also need a JavaScript HTML5 fix (see the HTML5)
 +  * [[http://www.bruceontheloose.com/htmlcss/examples/chapter-11/html5-elements-styling.html|See page]]
  
-Changing the Background+----
  
-    To use a background image:+<code css> 
 +charset "utf-8";
  
-#wrap {  +/* Style new "block-level-like" HTML5 elements so they occupy their own line in older browsers*/ 
-  background-image: url(bluebench.jpg); +article, aside, figcaption, figure, footer, header, hgroup, menu, nav, section { 
-  background-position: left top; + displayblock;
-  background-repeatrepeat;+
 } }
 +</code>
  
 +===== The CSS Reset =====
  
 +  * Common technique, ensures that design starts from a blank slate on all browsers
 +  * [[http://www.bruceontheloose.com/htmlcss/examples/chapter-11/reset.html|See result]]
  
-Notes+----
  
-    To change the background colour:+<code css> 
 +/* CSS RESET 
 +------------------------------------------------ */ 
 +/* http://meyerweb.com/eric/tools/css/reset/  
 +   v2.0 | 20110126 
 +   License: none (public domain) 
 +*/
  
-# wrap backgroundurl(bench.jpg) left top repeat} +html, body, div, span, applet, object, iframe, 
-#screen { background#FEF6F8} +h1, h2, h3, h4, h5, h6, p, blockquote, pre, 
-a:focus a:hover a:active { background: #F3CFB6} +a, abbr, acronym, address, big, cite, code, 
-#sidebar { background#F5F8FA; }+del, dfn, em, img, ins, kbd, q, s, samp, 
 +small, strike, strong, sub, sup, tt, var, 
 +b, u, i, center, 
 +dl, dt, dd, ol, ul, li, 
 +fieldset, form, label, legend, 
 +table, caption, tbody, tfoot, thead, tr, th, td, 
 +article, aside, canvas, details, embed,  
 +figure, figcaption, footer, header, hgroup,  
 +menu, nav, output, ruby, section, summary, 
 +time, mark, audio, video { 
 + margin0
 + padding0
 + border0; 
 + font-size100%; 
 + fontinherit
 + vertical-alignbaseline; 
 +} 
 +</code>
  
 +===== Changing the Background ====
  
-Notes+    To use a background image: 
 +<code css> 
 +#container { 
 +  background: url(../img/bg-bluebench.jpg) repeat-y; 
 +
 +</code>
  
-Setting the Height or Width for the Element+[[http://www.bruceontheloose.com/htmlcss/examples/chapter-11/assets/css/background-image.css|See result]]
  
-    To set the height or width for an element: 
  
-#wrap { width: 90%; max-width: 900px; min-width: 480px; }+==== To change the background colour ====
  
-#main {width75%; }+<code css> 
 +#page background#fef6f8 } 
 +a:focus  
 +a:hover  
 +a:active { background: #F3CFB6; } 
 +.logo a:hover { background: transparent;
 +.sidebar { background: #f5f8fa; } 
 +</code>
  
-.photo { width100px; height: 75px; }+[[http://www.bruceontheloose.com/htmlcss/examples/chapter-11/background-shorthand.html|See result]]
  
 +===== Setting the Height or Width for the Element =====
  
 +  * [[http://www.bruceontheloose.com/htmlcss/examples/chapter-11/width-height.html|Width and Height]]
 +  * [[http://www.bruceontheloose.com/htmlcss/examples/chapter-11/max-width.html|Maximum Width]]
  
-[Setting the width and height of an element] 
  
-Notes 
  
-Setting the Margins around an Element (1)+===== Setting the Margins around an Element =====
  
-    The margin is the amount of transparent space between one element and the next, in addition to and outside any padding or border around an element. It is used to increase (or decrease) the white space around an element. +===== Adding Padding around an Element =====
-    When you set two values, the first is applied to the top and bottom margins, the second is applied to the left and right margins. Here we give the design a little extra space at the top and bottom. +
-    The auto margin setting centres the layout in the window by dividing the leftover 10% of the browser window width that is not used by the wrap div between the right and left margins.+
  
-#wrap { margin20px auto }+  * Padding is extra space around the contents of an element but within the border. You can change the padding's thickness but not its background. 
 +  * When you set four values for padding they are assigned to the top, right, bottom, and left, in that order. Here there will only be padding on the top and right:
  
-[Setting the wrap margin to 20 pixels] 
  
 +===== Making Elements Float =====
  
-Setting the Margins around an Element (2) 
  
-    The sidebar div will have a left margin of 74% which will overlap the space for the main content just enough to allow for some padding around the sidebar text. +===== Controlling Where Elements Float =====
-    The 110 pixel margin to the left of the main content will give us room for the photo later.+
  
-#sidebar { margin-left: 74%; } +===== Setting the Border =====
-.photo_text { margin-left: 110px; }+
  
-[Setting the margins for sidebar and photo text]+===== Offsetting Elements in the Natural Flow =====
  
-Adding Padding around an Element (1)+===== Positioning Elements Absolutely =====
  
-    Padding is extra space around the contents of an element but within the border. You can change the padding's thickness but not its background. +===== Positioning Elements in 3d =====
-    When you set four values for padding they are assigned to the top, right, bottom, and left, in that order. Here there will only be padding on the top and right:+
  
-#wrap { padding: 30px 20px 0 0 }+===== Determining How to Treat Overflow =====
  
-[Adding padding to the wrap]+===== Aligning Elements Vertically =====
  
-Adding Padding around an Element (2)+===== Changing the Cursor =====
  
-    Now we add padding to the contents of the screen div — to the top, left and bottom, but not the right: 
-    When you set four values for padding they are assigned to the top, right, bottom, and left, in that order. Here there will only be padding on the top and right: 
  
-#wrap { padding: 10px 10px 10px 0; } 
  
-[Adding padding to the screen] 
  
-Adding Padding around an Element (3) +===== Positioning Elements Absolutely =====
- +
-    When the screen background is set to white, we can see why no padding was needed on the left. +
- +
-[Making the screen background white] +
- +
-Offsetting Elements In the Natural Flow +
- +
-    Each element has a natural location in a page's flow. +
-    Moving the element with respect to this original location is called relative positioning. +
-    The surrounding elements are not affected — at all. +
- +
-.date { position: relative; top -1.1em; } +
-.description { position: relative; left: 1em; margin bottom: 0.2 em; } +
- +
-[Offsetting elements in the natural flow] +
- +
-Positioning Elements Absolutely +
- +
-    You can take elements out of the natural flow — and position the absolutely — by specifying their precise position with respect to the nearest positioned ancestor or to the body. +
-    First we set the position for the photo_text class so that photos will be positioned with respect to it (and not the body). +
- +
-.photo_text { position: relative; } +
- +
-    The negative left offset will pull the photo left and out of the photo_text box. +
- +
-.photo { position: absolute; left: -112px; top: 3px; } +
- +
-[Positioning elements absolutely] +
-Notes.+
  
 Affixing an Element to the Browser Window Affixing an Element to the Browser Window
Line 719: Line 719:
 More notes More notes
  
-Changing the Cursor+===== Changing the Cursor ======
  
-    When you point to a link, the cursor changes to a pointing hand and the link is highlighted +  * When you point to a link, the cursor changes to a pointing hand and the link is highlighted
- +
-[Normal link behaviour] +
- +
-    Because we are on the home page, the home link will be part of the current class. +
-    We can then change the cursor and the background of the home link so that it doesn't act like a link. +
- +
-a:hover,current { cursor: default; background: white; } +
- +
-[Changing the link style and cursor] +
- +
-Notes+
  
 Determining Where Overflow Should Go Determining Where Overflow Should Go
eg-146/lecture16.txt · Last modified: 2012/03/19 21:30 by eechris