http___www.kodadri.com_css_uredivanje__1.xml
1.1 1.2 1.3 1.4 2.1 3.1 4.1 4.2 5.1 6.1 6.2 6.3 7.1 8.1 9.1 10.1 10.2 11.1 12.1 23.1 24.1 25.1 26.1 27.1 28.1 29.1 30.1 31.1 32.1 33.1 34.1 35.1 36.1 38.1 39.1 41.1 41.2 41.3 41.4 41.5 42.1 43.1 43.2 44.1 44.2 45.1 45.2 46.1 51.1 52.1 53.1 54.1 55.1 56.1 57.1 58.1 59.1 60.1 61.1 62.1 63.1 64.1 65.1 67.1 67.2 68.1 69.1 70.1 70.2 71.1 72.1 73.1 75.1 76.1 77.1 78.1 79.1 80.1 81.1 82.1 83.1 84.1 85.1 86.1 87.1 88.1 89.1 90.1 92.1 93.1 93.2 94.1 94.2 94.3 94.4 94.5 94.6 94.7 95.1 96.1 96.2 97.1 97.2 98.1 98.2 98.3 98.4 103.1 105.1 106.1 107.1 107.2 107.3 110.1 111.1 115.1
Many companies like to put graphs on their websites. Quite often, these graphs can roughly be divided into two groups. Group one: graphically rich graphs, usually created by a graphics agency against a price per hour, that need to be removed from the website weeks after publication, because the data displayed is not accurate any longer and the image of the graph itself cannot be altered. Group two: graphs generated by server applications that show accurate information, but sometimes look jaggy and not too exciting, nor reflect the corporate style of the company they were created for. The goal is to create a column graph in which, for instance, the income development of this year of a certain company may be visualised against the year before. The graph I believe it would be nice to create a three dimensional tube, positioned in another tube that is cut half through. The inner tube represents the company’s turnover development of a certain month this year and the the outer tube represents the turnover of exactly the same month, yet in the year before. The illustration below demonstrates the graph that I would like to generate dynamically and completely drawn by the browser’s render-engine using CSS. Difficult, you may think? Dread not, nor be dismayed. The good news is: it’s not that hard. The structure The graph itself is positioned inside one large container: To make life easier for the end user, stripes were added to this division, by means of a background image. Within the division mentioned above, there’s a subdivision which is intended to be used for the graph’s scale. It’s named ‘columnGraphScale’ and is followed by the divisions for the months. The scale The markup containing the scale only would look like this: I choose to make every number dividable by hundred black, corresponding every fifth, darker line in the background. The CSS for the scale looks like this: div#columnGraph p { font-size: 9px; margin: 0px; height: 10px; width: 25px; text-align: right; display: block; padding: 0px 10px 0px 0px; overflow: hidden; color: gray; line-height: 9px; background: url(images/body.gif) no-repeat left center; div#columnGraph p b { color: black; Each paragraph has a fixed height of 10 pixels. This equals the interval distance of the background lines. It would harm the legibility of the numbers that are super imposed on the lines if the lines were visible through the numbers. Therefore do the paragraphs get an opaque background. As the background in this case contains a ramp, the background image of the parent division may be reused in order not to destroy the layout for that matter. The columns Each column consists of two major parts: the inner tube and the outer tube. Each of these elements will be translated from an in the markup. Of course an other element might have been used for this purpose, such as span or div, though by using an a-element the possibility is kept open to add a links to pages containing detailed information on the month concerned at any given time. Naturally, all style elements of the tubes will be declared in the CSS, except for the height of the tubes and the distance between the different columns. These must be written right into the markup as this information is content, not style and is thus due to change. The markup looks like this: For each of those two elements a background image, a width and a z-axis position are set in the CSS. a.oldResult { width: 38px; display: block; float: left; position: absolute; z-index: 1; font-size: 9px; text-decoration: none; background: url(images/columGraphColumSkin.gif) repeat-y center top; text-align: center; padding: 0px; margin: 0px 11px 0px 11px; bottom: 0px; color: black; An absolute positioning, a z-axis of 1 and the positioning set bottom will make sure that the tubes will grow upwards instead of down. For the background the image columnGraphColumSkin.gif was used, set vertically aligned top. - Left: Microsoft Internet Explorer 6.0 without PNG-24 transparency support and with GIF-replacement images. - Right:Other browsers, such as Mozilla FireFox, Safari, Opera and other browser with PNG-24 transparancy support. The GIF-format was used to keep all of the above compatible with Microsoft Internet Explorer 6-. In order not to waste most other browsers’ precious PNG-24 transparency support, nice, semi transparent and anti aliased PNG images were applied by means of a child selector hack. html>body a.oldResult { background: url(images/columGraphColumSkin.png) repeat-y center top; About the same was applied on the elements ‘newResult’ as on the elements ‘oldResult’, but with a z-index of 2, to make sure the inner tube will be drawn in front of the outer tube. a.newResult { width: 26px; display: block; float: left; background: url(images/columnGraphColumnCentre-new.gif) no-repeat center top; position: absolute; z-index: 2; font-size: 9px; color: black; text-decoration: none; text-align: center; margin: 0px 17px 0px 17px; padding: 0px; bottom: 0px; font-weight: bold; Both elements are pushed into position within the division that contains them: This division is used for displaying the column’s base. We need this image only in case there is no desire to use the outer tube in the graph. The images of the inner tube and the outer tube contain a certain top white space and the roundness causes the readout height (the horizontal cut through of the tubes’ top surface) to differ from the absolute height of the image. This value, including a few pixels that we need at the bottom to finish the bases, say twenty-four pixels, may be added to make up for the difference. The nicest way to to fix this would be to add a bottom margin of twenty-four pixels to the a-element in the CSS. An elegant solution yes, however, MSIE’s broken box model redirects this elegant solution straight to the dustbin. Therefore 24 pixels need to be added to each value. On my scale every five pixels equals a difference of ten. In this case the formula is: a-element height = 0.5 ∙ desired value %2B 24 The month januari was no bad month, as the turnover increased from a measly 492 to a good 660. This gives us, using the formula above, the values 270px and 354px and a matching graph. In order to make the base of the columns just as neat as the upper part, it has to be covered by an extra division with a background image. Another another div, containing the column titles is also added and the actual statistic data may be written down the a href of each tube to make sure there can be no misunderstanding about the readout of the results of this year. Problems could occur reading out last year’s result, when it sinks behind the inner tube. The outer tube however, is only used as a quick, visual indication to show whether turnovers went up or down and it’s value could be left out. I will add this value to markup however in this case the markup below is the result: januari The desired result is now there and adding the other eleven months will make the graph complete. The legend A graph like this, wherein multiple kinds of information are combined, needs a legend. As a legend is basically a list of all colours (or shapes) used in the graph and what they mean, it seems logical to use an unordered list for this in the markup. Each list element gets a class to differentiate them from each other. omzet 2003 omzet 2004 Last but not least adding a scale proportion of 1 : 1.000.000 will not only make this company’s results look much better, but will also finish the graph.
1.1 2.1 2.2 2.3 3.1 3.2 3.3 3.4 4.1 5.1 9.1 10.1 11.1 13.1 14.1 16.1 18.1 19.1 19.2 19.3 19.4 19.5 20.1 21.1 22.1 24.1 25.1 26.1 27.1 28.1 29.1 30.1 31.1 31.2 32.1 32.2 33.1 34.1 35.1 35.2 36.1 37.1 38.1 39.1 40.1 41.1 42.1 43.1 44.1 45.1 46.1 47.1 48.1 49.1 53.1 58.1 59.1 60.1 61.1 65.1 66.1 67.1 69.1 70.1 71.1 73.1 74.1 75.1 76.1 77.1 79.1 80.1 81.1 82.1 84.1 85.1 86.1 88.1 90.1 91.1 92.1 94.1 96.1 97.1 98.1 99.1 100.1
Opća pravila Na početku CSS datoteke uvijek pišemo @charset “utf-8”; zbog naše kodne stranice. Nakon toga nabrajamo selektore (to su nazivi elemenata stranice, npr. Svojstva selektora nabrajamo unutar vitičastih zagrada { }, a njihove vrijednosti iza znaka dvotočke : i točku-zarez ; pišemo na kraju reda. Što su zapravo selektori? Možemo ih zamisliti kao površine unutar kojih smještamo svoj sadržaj na stranicu (tekst, slike itd). Svakom tom sadržaju treba odrediti lokaciju, dimnezije, boju, okvir, udaljenost od ostalog sadržaja i mnogo drugih svojstava. Korištenje pojedinih svojstava ovisi o nama samima i o želji klijenta za kojeg radimo web stranicu. Pravila korištenja selektora: Upisati selektor u HTML datoteku: Upisati taj isti selektor i njegova svojstva u CSS datoteku: #main { width: 770px; margin: 2px; background-color: #000; Upisati u zaglavlje (HEAD) HTML datoteke putanju do CSS datoteke: Grupiranje selektora Ako više selektora ima neke zajednička svojstva, onda ih možemo grupirati. Na taj način ne moramo istu stvar više puta pisati. Kasnije možemo za svaki posebno navesti svojstva po kojima se razlikuju. U donjem primjeru svi selektori imaju isti razmak između sadržaja i ruba elementa i margine. Sve ostale razlike mogu se posebno naknadno navesti u svakom selektoru posebno. #container, #header, #main, #sidebar, #footer { padding: 10px; margin: 10px; Uređivanje teksta Kod uređivanja teksta možemo koristiti sljedeće naredbe: color: boja slova; font-size: veličina slova; font-style: stil slova; font-family: oblik slova; Uređivanje elemenata Elementi CSS-a su najčešće nevidljvi okviri (boxovi) u koje stavljamo pojedine dijelove stranice. To su zapravo ti naši selektori. Nekad je zgodno prije samog početka izrade stranice, skicirati stranicu na papiru tako da otprilike vidimo kakav razmještaj želimo. Na slici ispod ovog odlomka nalazi se jedan primjer takve stranice. Ispod se nalaze najčešće korišteni nazivi elemenata stranice: Container – prikazan je svijetlo zelenom bojom i on prikazuje element u koji smještamo ostale bitne dijelove. Header (zaglavlje) – prikazan je plavom bojom. Tu obično ide neki logo (slika ili flash). Sidebar – može stajati bilo gdje (na ovoj slici je nalazi se lijevo) i obično sadrži linkove ili popis zadnjih ili načitanijih vijesti. Main – to je obično glavni ili srednišnji dio (na ovoj slici nalazi se desno) gdje stavljamo tekstove i slike. Footer (podnožje) – nalazi se u podnožju. Ovo su samo neki elementi koje možemo koristiti. Što se sve može definirati elementima? width: širina; height: visina; background-color: boja pozadine; background-image: pozadinska slika; background-repeat: slika i dio slike koji se ponavlja ili ne ponavlja; margin: debljina margine; padding: udaljenost sadržaja od ruba elementa; border: obrub; HTML kod za gornji primjer: Ovo je samo kostur stranice Zaglavlje Lijevi dio Desni dio Podnožje CSS za gornji primjer: body { color:white; #container, #header, #main, #sidebar, #footer { padding: 10px; margin: 10px; #container { background-color: lightgreen; width: 800px; height: 710px; margin: 10px auto; #header { background-color: blue; width: 760px; height: 200px; #sidebar { background-color: green; float: left; height: 300px; #main { background-color: green; float: left; height: 300px; #footer { background-color: red; clear: both; width:760px; height: 100px;