Presentation is loading. Please wait.

Presentation is loading. Please wait.

LIS650 lecture 4 Thomas Krichel 2004-10-24. today Advice CSS Properties –Box properties –List properties –Classification properties Fun with selectors.

Similar presentations

Presentation on theme: "LIS650 lecture 4 Thomas Krichel 2004-10-24. today Advice CSS Properties –Box properties –List properties –Classification properties Fun with selectors."— Presentation transcript:

1 LIS650 lecture 4 Thomas Krichel 2004-10-24

2 today Advice CSS Properties –Box properties –List properties –Classification properties Fun with selectors More CSS properties –Generated content properties –User interface properties –Page properties

3 advice for cheaters Within a style sheet, for example the contents of a element, you can import another file using the @import command @import url(; or @import ""; these two ways appear to be equivalent

4 media dependent styles Remember the media CSS knows about ? Using @import, you can import different types for different media @import "URI" medialist where medialist is a list of one or more media, separated by comma Example @import challenged.css" braille, handheld

5 advice about spacing Traditionally only use horizontally, the em nowadays is the height of the font, and should be used vertically as well, as in {padding: 1.5em; margin: 1.5em} For body, use %ages, as in body {margin-left: 15%; margin-right: 0%} To create a menu, do something like {float: left; width: 15em}

6 the 'inherit' value Each property can have the 'inherit' value. In this case, the value of the property for the element is determined by the containing element. Sometimes, 'inherit' is the default value.

7 validating CSS It is at Check your style sheet there when you wonder why the damn thing does not work. Note that checking the style sheet will not be part of the assessment of the web site.

8 box properties V {z-index: } let you set an integer value for a layer on the canvas where the element will appear. If element 1 has z-index value 1 and element 2 has z-index value number 2, element 2 lies on top of element 1. A negative value means that the element contents is behind its containing block. the initial value is 'auto'. browser support for this property is limited.

9 general background to foreground order For an element, the order is approximately –background and borders of element –children of the element with negative z-index –non-inline in-flow children –children that are floats –children that are in-line in-flow –children with z-index 0 or better not worth remembering for quiz

10 box properties VI The {visibility: } property sets the visibility of a tag. It takes values –'visible' The generated box is visible. –'hidden' The generated box is invisible (fully transparent), but still affects layout. –'collapse' The element collapses in the table. Only useful if applied to table elements. Otherwise, 'collapse' has the same meaning as 'hidden'. With this you can do sophisticated alignments

11 box properties VII We now look at overflow and clipping. When a box contents is larger than the containing box, it overflows. {overflow:} can take the values –visible contents is allowed to overflow –hidden contents is hidden –scroll UA displays a scroll device at the edge of the box –auto leave to the user agent to decide what to do

12 box properties VIII The {clip:} properties sets which area of a box is visible. When the {overflow: } property is not set to 'hidden' it will take no effect. It only applies to absolutely positioned elements. p {overflow: hidden; clip: rect(15px, -10px, 5px, 10px)} IE v6 does not support it. Example at clip_test.html in the examples section of the class web site.

13 box properties IX {min-height:} sets the minimum height of a box {max-height:} sets the maximum height of a box They can take length values or they can use a percentage of the containing block. The containing block is usually the parent element.

14 list properties {list-style-position: } can take the value inside or outside. The latter is the default, the property refers to the position of the list item start marker {list-style-property: } –takes the values disc, circle, square, none with an unordered list –takes the value decimal, lower-roman, upper- roman, lower-alpha, upper-alpha with ordered list, and some others {list-style-image: } define the bullet point of a list as a graphic, use url(URL) to give the location of the graphic.

15 classification properties I {display: } sets the display type of an element, it take the following values –'block' displays the tag contents as a block –'inline' displays it as inline contents –'list-item' makes it an item of a list, you can then attach list properties to it –'none' does not display it –'run-in' (see later) –'compact'(see later)

16 classification properties II {display: } also takes the following values –table-- table-footer-group –table-row -- table-row-group –table-cell-- table-column –table-caption -- table-column-group –inline-table-- table-header-group these means that they behave like the table elements that we already discussed

17 run-in box If a block box (that does not float and is not absolutely positioned) follows the run-in box, the run-in box becomes the first inline box of the block box. Otherwise, the run-in box becomes a block box. Example on next page

18 example for run-in box a run-in box example h3 { display: run-in } a run-in heading and a paragraph of text that follows it and it continues on the line of the h3

19 compact box If a block-level box follows the compact box, the compact box is formatted like a one-line inline box. The resulting box width is compared to one of the side margins of the block box, –left margin if direction is left-to-right –right margin if direction is right-to-left If the inline box width is less than or equal to the margin, the inline box is given a position in the margin as described immediately below. Otherwise, the compact box becomes a block box.

20 compact box example <div style="dt { display: compact } dd { margin-left: 4em }> short description goes here. too long for the margin description goes here.

21 classification properties III The {whitespace:} property controls the display of white space in a block level tag. –'normal' collapses white space –'pre' value similar to tag –'nowrap' ignores carriage returns only It seemed not to work in firefox last time I tried. now we turn to cool selectors

22 remember the basic selector The basic selector is a comma-separated list of elementary selectors. Often, the elementary selectors are HTML elments, e.g. h1, h2 {text-align: center} will center all and element contents but the selectors can be more precise

23 class selectors This is the standard way to style up a class.class { property1: value1, property2: value2 …} will give all the properties and values to any element in the class class. Recall HTML, when you have set the you can apply the class will apply all the attributes of the class class to the element element. Note that you can place any tag into several classes, use blanks to separate the class names

24 fun with selectors * selects any element. E selects any element called E E F selects any F element that is in the contents of an E element, as a child, grand-child etc E > F selects any F tag that is a child of an E element. This is more restrictive than the previous selector. E:first-child selects E when E is the first child of its enclosing element E:link selects an E element if it is in the contents of an element

25 more selectors E:visited selects element E if E if it is in the contents of a link and the link has been visited. E:active, E:hover, E:focus selects element E during certain user actions with the mouse. E:lang(c) selects element E if it is in the human language c E + F selects any F element immediately preceded by an E element start tag.

26 more selectors E[a] selects any E element with an attribute "a", whatever the value E[a="v"] select any E element whose "a" attribute value is exactly equal to "v". E[a~="v"] selects any element E whose "a" attribute value is a list of space-separated values, one of which is exactly equal to "v". Useful for classes, because you can put an element into several classes, separated by blanks.

27 more selectors E[lang|="en"] selects any E element whose "lang" attribute has a hyphen-separated list of values beginning (from the left) with "en". This would select all en languages, be they en-us or en-gb E:first-letter selects the first letter in the content of element E E:first-word selects the first word in the contents of element E

28 convenient shorthand We have already seen some. E.m is a convenient shorthand for E[class~="m"] E#myid is a convenient shorthand for E[id="myid"].m is a convenient shorthand for *.m

29 E:before and E:after E:before or E:after can be used to add contents before or after a element E. We will deal come to these when we discuss generated contents properties. This will be coming up after the examples for selectors that we will discuss now.

30 examples h1, h2, h3 { font-family: sans-serif } h1 { color: red } em { color: red } h1 em { color: blue } div * p div p *[href] body > p { line-height: 1.3 } div ol > li p

31 more example h1 + p {text-indent: 0} h1 + h2 {margin-top: -5mm} h1.opener + h2 {margin-top: -5mm} h1[title] {color: blue} span[class="example"] {color: blue } span[hello="Cleveland"][goodbye="Columbus"] { color: blue} a[rel~="copyright"] {color: red} a[href=""] {background-color: grey} *[lang=fr] {display: none}

32 more examples *[lang|="en"] {color : red }.dialog.romeo {voice-family: "Lawrence Olivier", charles, male} a:link {color: red} /* unvisited links */ a:visited {color: blue} /* visited links */ a:hover {color: yellow} /* user hovers */ a:active {color: lime} /* active links */ a.external:visited {color: blue}

33 more examples html:lang(fr) { quotes: '« ' ' »' } html:lang(de) { quotes: '' '} *:lang(fr) > q { quotes: '« ' ' »' } *:lang(de) > q { quotes: '' '} (quotation style depending on the surrounding language, not the language of the quote!)

34 more examples a[rel~="copyright"] a[href=""] div > p:first-child a:focus:hover p > * > p div[class~="ny"][id="albany"]

35 example: drop caps with uppercase CSS p { font-size: 12pt; line-height: 12pt } p:first-letter { font-size: 200%; font-style: italic; font- weight: bold; float: left } span { text-transform: uppercase } HTML The first few words of an article in The Economist.

36 generated contents properties generated contents is, for example, the bullet appearing in front of a list item. {content:} can be used with the :before and :after selectors.The content can be –a text string –a url(URL) where the contents is to be found –a attr(att) where att is the name of the attribute, the content of which is being inserted Example p.note:before {content: "note"} will insert the string "note" before any paragraph in the class 'note'.

37 generated contents properties II Here are some counter properties –{counter-reset: counter} resets a counter counter –{counter-increment: counter} increments a counter –{counter(counter)} uses the counter Example h1:before {counter-increment: chapter_counter; counter-reset: section_counter; content: "Chapter " counter(chapter_counter) ":"} and then we can use h2 for the sections, of course! browser support uncertain!

38 user interface properties I There is a {cursor:} property to change the shape of the cursor. It takes the following values –auto-- crosshair-- default –pointer (something suggesting a link) –e-resize –ne-resize –nw-resize –n-resize –se-resize –sw-resize, --s-resize –w-resiz (Indicate that some edge is to be moved) –text (usually as an I) --wait (watch or hourglass) –help (question mark or balloon) –url (with a uri to svg file, that has the graphic to show) use these to totally confuse your users

39 user interface properties II outlines are like borders, but they don't take up space. they are decorative shades drawn around some {outline-width: } sets the width {outline-style: } takes the same values as {border- style: } {outline-color: } has a color value.

40 paged media support I CSS has the concept of a page box in which paged output should be placed into. @page rule can be used to specify the size of the page @page {size: 8.5in 11in} Valid values are one or two lengths and they words portrait and landscape. The latter will depend on the default print sheet size, country- specific.

41 paged media support II You can add {margin: }, {margin-top: }, {margin- left: }, and {margin-right: } properties. They will add to the margins that the printer will set by default. The default printer margins are beyond your control. You can add a {marks: crop} property to add crop marks You can add a {mark: cross} property to create registration marks.

42 paged media support III You can use three pseudoclasses to specify special cases –:first for the first page –:left for any left page –:right for any right page Example –@page :first {margin-top: 3in}

43 named pages You can give a page rule an optional name. Example @page rotated { size: landscape} Then you can use this with the page property to specify specific ways to print things. Example table {page: rotated} will print the table on a landscape sheet. This comes in handy for bulky tables.

44 actual page breaking Pages will break if –the current page box flows over or if –a new page format is being used with a {page: } property You can take some control with the {page-break- before: } and {page-break-after: } properties. They take the values –auto– always – avoid– left– right The latter two make sure that the element is on a left or right page. Sometimes this will require two page breaks.

45 conclusions These are not all the properties. Audio properties are still missing But I am not sure if I should go into more.

46 Thank you for your attention!

Download ppt "LIS650 lecture 4 Thomas Krichel 2004-10-24. today Advice CSS Properties –Box properties –List properties –Classification properties Fun with selectors."

Similar presentations

Ads by Google