<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>/home/antu &#187; CSS</title>
	<atom:link href="http://www.antusblog.de/category/webgestaltung/css-webgestaltung/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.antusblog.de</link>
	<description>Linux, Programmierung und andere Dinge die mich interessieren</description>
	<lastBuildDate>Mon, 26 Oct 2009 06:00:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>CSS: DIV-Element mit 100% Höhe</title>
		<link>http://www.antusblog.de/2009/10/22/css-div-element-mit-100-hohe/</link>
		<comments>http://www.antusblog.de/2009/10/22/css-div-element-mit-100-hohe/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 06:00:32 +0000</pubDate>
		<dc:creator>Antu</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[100% Höhe]]></category>
		<category><![CDATA[DIV]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Webgestaltung]]></category>

		<guid isPermaLink="false">http://www.antusblog.de/?p=2229</guid>
		<description><![CDATA[Manchmal ist es gewollt, dass ein HTML-Element (meistens ein DIV) 100% der Höhe des Browser-Fensters einnehmen soll. Mit einem einfachen height:100%; ist es aber nicht getan. Wie man ein DIV-Element erstellt, dass 100% der Höhe des Browser-Fensters hat aber bei längerem Inhalt mitwächst, und was dabei zu beachten ist, erkläre ich in diesem Artikel. Der [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.antusblog.de/?p=2229"><img class="alignright size-full wp-image-2230" title="100% Hoehe" src="http://www.antusblog.de/wp-content/uploads/2009/10/100.Prozent.Hoehe.png" alt="100% Hoehe" width="150" height="150" /></a>Manchmal ist es gewollt, dass ein HTML-Element (meistens ein DIV) 100% der Höhe des Browser-Fensters einnehmen soll. Mit einem einfachen <code>height:100%;</code> ist es aber nicht getan. Wie man ein DIV-Element erstellt, dass 100% der Höhe des Browser-Fensters hat aber bei längerem Inhalt mitwächst, und was dabei zu beachten ist, erkläre ich in diesem Artikel.</p>
<p><span id="more-2229"></span></p>
<h2>Der Aufbau: HTML</h2>
<p>Der HTML-Quelltext hierzu ist einfach, es wird ein DIV-Element erstellt, welches alle weiteren Inhalte umfasst. Dieses bekommt eine Klasse, oder besser eine ID zugewiesen, damit es leichter per CSS gestaltet werden kann.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wrapper&quot;</span>&gt;</span>
            [...]
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span></pre></div></div>

<h2>HTML und BODY</h2>
<p>Damit, dem DIV nun einfach eine Höhe von 100% zuzuweisen, ist es noch nicht getan. Die 100% beziehen sich ja auf die Größe des Eltern-Elements, dem <code>BODY</code>, dieser braucht also auch eine Höhe von 100%. Das <code>HTML</code>-Element bekommt ebenfalls eine Höhe von 100%, schließlich ist es ja das Eltern-Element von <code>BODY</code>.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">html<span style="color: #00AA00;">,</span> body <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Viele Browser geben dem <code>HTML</code> oder dem <code>BODY</code>-Element standardmäßig noch einen kleinen Innenabstand, so dass die Inhalte nicht direkt am Rand kleben. In diesem Fall ist das aber unerwünscht, denn einerseits soll das DIV-Element ja die ganze Höhe ausfüllen (ohne andersfarbige Ränder), und andererseits gäbe es sonst Scrollbalken (100% + 5px Innenabstand oben = mehr als 100% -> Scrollbalken).</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">html<span style="color: #00AA00;">,</span> body <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h2>DIV-Element auf 100% der Höhe von BODY</h2>
<p>Jetzt wo das BODY- und das HTML-Element auf 100% Höhe sind, muss nur noch das DIV-Element auf 100% Höhe gebracht werden:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#wrapper</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #808080; font-style: italic;">/* Für moderne Browser */</span>
    <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* Für den Internet Explorer 6 */</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span> !important<span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Das Element soll eine Mindesthöhe von 100% haben, bei längeren Inhalten soll es sich von selbst vergrößern. Eine Mindesthöhe kann mit der CSS-Eigenschaft <code>min-height</code> angegeben werden, würde man hier <code>height</code> verwenden, würden moderne Browser nicht zulassen, dass das DIV-Element mit längeren Inhalten mitwächst, es wäre immer genau 100% hoch. Der Internet Explorer 6 hingegen versteht die <code>height</code>-Eigenschaft als Mindesthöhe, <code>min-height</code> kennt der IE 6 nicht.
<p>Hier kann man sich die Tatsache zu Nutze machen, das der IE 6 <a href="http://www.kk-works.de/2005/10/12/ie-vorurteile/">!important</a> etwas anders interpretiert als andere Browser. Zuerst legt man fest, dass die Höhe des Elements sich dem Inhalt anpassen soll (<code>auto</code>), und das diese Angabe alle anderen Angaben zur Höhe überschreibt (<code>!important</code>). Dann wird dem Element eine Höhe von 100% zugewiesen, was der IE 6 als Mindesthöhe interpretiert. Da der IE 6 das <code>!important</code> in diesem Fall ignoriert, verwendet er die zweite Angabe, und stellt eine Mindesthöhe von 100% ein. Alle anderen Browser beachten das <code>!important</code>, und ignorieren die zweite <code>height</code>-Angabe.</p>
<p>In Aktion sieht das dann so aus: <a href="/demos/12-seite-mit-100-prozent-hoehe/Beispiel.html">Beispiel</a></p>
<h2>Eine Fußzeile?</h2>
<p>Wie erstellt man jetzt eine Fußzeile? Dazu wird ein DIV-Element mit der ID <em>footer</em> erstellt, dieses wird mit CSS wie folgt gestaltet:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#footer</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">2em</span>
 <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Mittels <code>position:absolute;</code> wird festgelegt, dass das Element relativ zum nächsthöheren positionierten Element ausgerichtet wird. Mit <code>bottom:0;</code> bestimmt man, dass das Fußzeilen-Element ganz am unteren Rand vom <code>wrapper</code>-Element positioniert wird.</p>
<p>Nun muss dem <code>wrapper</code>-Element allerdings noch eine relative Positionierung zugewiesen werden, damit das Fußzeilen-Element sich darauf beziehen kann.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#wrapper</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #808080; font-style: italic;">/* Für moderne Browser */</span>
    <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* Für den Internet Explorer */</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span> !important<span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100%</span><span style="color: #00AA00;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Der Inhalt selbst bekommt auch ein eigenes DIV-Element, welches einen Innenabstand so hoch wie die Fußzeile bekommt, so dass die Inhalte nicht unter der Fußzeile angezeigt werden.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wrapper&quot;</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span>&gt;</span>
                [Inhalte]
            <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
            <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;footer&quot;</span>&gt;</span>
                [Inhalte der Fußzeile]
            <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span></pre></div></div>

<p>Das CSS für das <code>content</code>-DIV sieht so aus:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#content</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">2em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Fertig sieht das dann so aus: <a href="/demos/12-seite-mit-100-prozent-hoehe/Beispiel2.html">Beispiel</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.antusblog.de/2009/10/22/css-div-element-mit-100-hohe/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fortschrittsbalken mit CSS/JavaScript</title>
		<link>http://www.antusblog.de/2009/07/27/fortschrittsbalken-mit-cssjavascript/</link>
		<comments>http://www.antusblog.de/2009/07/27/fortschrittsbalken-mit-cssjavascript/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 20:48:28 +0000</pubDate>
		<dc:creator>Antu</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Java Script]]></category>
		<category><![CDATA[dwProgressBar]]></category>
		<category><![CDATA[Fortschrittsanzeige]]></category>
		<category><![CDATA[Fortschrittsbalken]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jQuery UI]]></category>
		<category><![CDATA[jsProgressBarHandler]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[Prototype]]></category>

		<guid isPermaLink="false">http://www.antusblog.de/?p=1798</guid>
		<description><![CDATA[Fortschrittsbalken werden vor allem bei Webanwendungen gebraucht, die mit dem Benutzer interagieren, beispielsweise beim Hochladen von Dateien oder um den Fortschritt in einem Formular anzuzeigen. Aber auch bei anderen Webanwendungen können Fortschrittsbalken sinnvoll sein, beispielsweise um den aktuellen Stand eines noch nicht fertiggestellten Projektes anzuzeigen oder den noch verfügbaren Speicherplatz, o.Ä. In dieser Anleitung erkläre [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.antusblog.de/wp-content/uploads/2009/07/jQueryUI-FSB.png"><img class="aligncenter size-full wp-image-1799" title="Fortschrittsbalken" src="http://www.antusblog.de/wp-content/uploads/2009/07/jQueryUI-FSB.png" alt="Fortschrittsbalken" width="500" height="150" /></a>Fortschrittsbalken werden vor allem bei Webanwendungen gebraucht, die mit dem Benutzer interagieren, beispielsweise beim Hochladen von Dateien oder um den Fortschritt in einem Formular anzuzeigen. Aber auch bei anderen Webanwendungen können Fortschrittsbalken sinnvoll sein, beispielsweise um den aktuellen Stand eines noch nicht fertiggestellten Projektes anzuzeigen oder den noch verfügbaren Speicherplatz, o.Ä.</p>
<p>In dieser Anleitung erkläre ich wie man einfache Fortschrittsbalken mit CSS erstellen kann, und stelle 4 JavaScript-Skripte vor mit denen sich &#8220;bewegliche&#8221; Fortschrittsbalken erstellen lassen.</p>
<p><span id="more-1798"></span></p>
<h2>Einfache Fortschrittsbalken</h2>
<p>Fortschrittsbalken mittels CSS zu erstellen ist nicht weiter schwer, man braucht im Grunde nur zwei Elemente, die übereinander gelegt werden.</p>
<h3>Ohne Bilder</h3>
<p><a href="http://www.antusblog.de/wp-content/uploads/2009/07/Einfacher.Fortschrittsbalken.ohne.Bilder.png"><img class="aligncenter size-full wp-image-1802" title="Einfacher Fortschrittsbalken ohne Bilder" src="http://www.antusblog.de/wp-content/uploads/2009/07/Einfacher.Fortschrittsbalken.ohne.Bilder.png" alt="Einfacher Fortschrittsbalken ohne Bilder" width="300" height="100" /></a>Man erstellt ein Element, gibt ihm eine Hintergrundfarbe und weist ihm eine Breite/Höhe zu. In diesem Element erstellt man nun ein zweites Element, dem man ebenfalls eine Hintergrundfarbe (möglichst eine andere, als die vom ersten Element) und die gleiche Höhe wie dem ersten Element zu. Die Breite des zweiten Elements gibt dann an, welchen Wert der Fortschrittsbalken anzeigen soll.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span>&gt;</span>
  div.fsb {
    border:1px solid #000;
    background-color:white;
    width:200px;
    height:28px;
    padding:1px;
  }
&nbsp;
  div.fortschritt {
    background-color:#000;
    height:28px;
    width:50%; /* Fortschritt */
  }
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- [...] --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fsb&quot;</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fortschritt&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>In Aktion sieht das dann so aus: <a href="/demos/8-fortschrittsbalken/cssbalken/ohnebilder.html">Demo</a>.</p>
<h3>Mit Bildern</h3>
<p><a href="http://www.antusblog.de/wp-content/uploads/2009/07/Einfacher.Fortschrittsbalken.mit.Bildern.png"><img src="http://www.antusblog.de/wp-content/uploads/2009/07/Einfacher.Fortschrittsbalken.mit.Bildern.png" alt="Einfacher Fortschrittsbalken mit Bildern" title="Einfacher Fortschrittsbalken mit Bildern" width="350" height="125" class="aligncenter size-full wp-image-1805" /></a>Möchte man den Fortschrittsbalken etwas schöner gestalten, kann man natürlich auch Bilder verwenden, die Methode funktioniert eigentlich genau so. Der einzige Unterschied ist, das anstatt von Hintergrundfarben Bilder verwendet werden.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #6666ff;">.fsb</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'normal.png'</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
div<span style="color: #6666ff;">.fortschritt</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'farbig.png'</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">50%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>In Aktion sieht das dann so aus: <a href="/demos/8-fortschrittsbalken/cssbalken/mitbildern.html">Demo</a>.</p>
<h2>JavaScript-Fortschrittsbalken</h2>
<p>Mit JavaScript kann man den Fortschrittsbalken auch Leben einhauchen, bzw. den angezeigten Wert verändern. Ein einfaches JS-Skript, welches die Breite des inneren Elements ändert ist schnell geschrieben. Im folgenden stelle ich allerdings 4 Skripte/Klassen vor, die noch etwas mehr können als nur das. Das erste Skript basiert auf jQuery/jQuery UI, das zweite benötigt nur jQuery, das dritte ist für Prototype und das vierte verwendet mootools.</p>
<p>Ich habe für jedes Skript eine Demo erstellt: <a href="/demos/8-fortschrittsbalken/jsbalken/fortschrittsbalken.html">Fortschrittsbalken-Demo</a></p>
<h3>jQueryUI &#8211; ProgressBar</h3>
<p><a href="http://www.antusblog.de/wp-content/uploads/2009/07/Fortschrittsbalken.mit.jQueryUI.png"><img src="http://www.antusblog.de/wp-content/uploads/2009/07/Fortschrittsbalken.mit.jQueryUI.png" alt="Fortschrittsbalken mit jQuery UI" title="Fortschrittsbalken mit jQuery UI" width="500" height="100" class="aligncenter size-full wp-image-1811" /></a>Die JS-Bibliothek <a href="http://jqueryui.com/">jQuery UI</a> stellt diverse Werkzeuge und Benutzeroberflächen-Elemente bereit. Unter anderem bietet sie auch eine Klasse zur Erstellung von Fortschrittsbalken. Praktischerweise kann man auf der Download-Seite von jQuery UI direkt die Elemente angeben, die man benötigt, so braucht man nicht die ganze Bibliothek runterzuladen/einzubinden (wenn man nur den Fortschrittsbalken braucht), und spart so einiges an Speicherplatz/Datentransfer. Die Bibliothek basiert auf <a href="http://jquery.com/">jQuery</a>, dieses muss also auch eingebunden werden.</p>
<p>Eine Besonderheit von jQuery UI: Das Aussehen der Benutzeroberfläche (und somit des Fortschrittsbalkens) wird durch Themen festgelegt. Auf der Webseite von jQuery UI findet sich (unter Gallery) bereits eine kleine Auswahl von fertigen Themen, natürlich ist es auch möglich eigene Themen zu erstellen. Das Thema wird über eine css-Datei definiert, diese muss ebenfalls in die Seite eingebunden werden.</p>
<h4>Einbinden</h4>
<p>Benötigt werden: jQuery, jQuery UI (Progressbar), und ein jQuery UI Thema.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery-ui/css/ui-lightness/jquery-ui-1.7.2.custom.css&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery-ui/js/jquery-1.3.2.min.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery-ui/js/jquery-ui-1.7.2.custom.min.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>(Die Pfade müssen eventuell angepasst werden.)</p>
<h4>HTML</h4>
<p>Man erstellt einfach ein div-Element, den Rest erledigt das Skript. Dem Element kann man noch eine ID geben, das macht es leichter es anzusprechen.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fsb&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<h4>Fortschrittsbalken erstellen</h4>
<p>Um den Balken zu erstellen, selektiert man das Ziel-Element mit der <code>$()</code>-Funktion, und ruft die Methode <code>progressbar()</code> auf. Mittels dem Parameter <code>value</code> kann man den Ausgangswert des Fortschrittsbalkens angeben. Außerdem kann man, wenn man möchte, mit dem Parameter <code>change</code> auch gleich eine Funktion festlegen, welche aufgerufen wird, wenn der Wert sich ändert. Beide Parameter sind optional.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#fsb'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">progressbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        value<span style="color: #339933;">:</span><span style="color: #CC0000;">50</span><span style="color: #339933;">,</span>
        change<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
            <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#fsb'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">progressbar</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'option'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'value'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'%'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h4>Methoden und Ereignisse</h4>
<p>Die Klasse bietet Methoden zum Abfragen und Ändern des angezeigten Werts, sowie ein Ereignis welches ausgelöst wird, wenn der Wert sich ändert.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Wert aendern</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#fsb'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">progressbar</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'option'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'value'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// Wert abfragen</span>
<span style="color: #003366; font-weight: bold;">var</span> wert <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#fsb'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">progressbar</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'option'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'value'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Weitere Informationen zu der Klasse und ihren Methoden finden sich in der <a href="http://jqueryui.com/demos/progressbar/">offiziellen Dokumentation</a>.</p>
<h3>jQuery &#8211; ProgressBar</h3>
<p><a href="http://www.antusblog.de/wp-content/uploads/2009/07/Fortschrittsbalken.mit.jQueryProgressBar.png"><img src="http://www.antusblog.de/wp-content/uploads/2009/07/Fortschrittsbalken.mit.jQueryProgressBar.png" alt="Fortschrittsbalken mit jQuery Progress Bar" title="Fortschrittsbalken mit jQuery Progress Bar" width="500" height="100" class="aligncenter size-full wp-image-1821" /></a>Das Skript <a href="http://t.wits.sg/2008/06/20/jquery-progress-bar-11/">jQuery Progress Bar</a> basiert auf jQuery und bietet einige nützliche Funktionen, die die jQuery UI-Variante nicht hat. Es ist möglich verschiedene Bilder zur Anzeige des Fortschritts zu verwenden, so kann man beispielsweise für die ersten 10-20% einen roten Hintergrund, für die nächsten 10-20% dann einen orangen, dann einen gelben und zum Schluss einen grünen Hintergrund verwenden. Es lässt sich auch festlegen ob neben dem Balken auch der Fortschritt noch einmal als Prozentzahl angezeigt werden soll, und auch eine Anzeige des genauen Wertes (123/465) ist möglich. Außerdem ist die Bewegung des Fortschrittsbalkens animiert, es lässt sich sogar die Geschwindigkeit der Animation festlegen. </p>
<h4>Einbinden</h4>
<p>Benötigt werden jQuery und das Skript selbst.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery-ui/js/jquery-1.3.2.min.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.progressbar/js/jquery.progressbar.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<h4>HTML</h4>
<p>Auch bei diesem Skript wird nur ein <code>div</code>-Element benötigt, den Rest erstellt das Skript selbst.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fsb&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<h4>Fortschrittsbalken erstellen</h4>
<p>Erstellt wird der Fortschrittsbalken mittels der Funktion <code>progressBar()</code>. Dabei gibt es einige Parameter, mittels derer das Aussehen und Verhalten des Fortschrittsbalkens beeinflusst werden können:</p>
<ul>
<li><code>steps</code> und <code>step_duration</code>: Geben an, wie viele Schritte beim Ändern des Anzeigewertes gegangen werden sollen, und wie lange ein Schritt dauert. (Standard: <code>20</code>/<code>20</code>)</li>
<li><code>max</code>: Der max. Wert, bis zu dem der Fortschrittsbalken geht. (Standard: <code>100</code>)</li>
<li><code>showText</code> und <code>textFormat</code>: Ob neben dem Balken noch der Fortschritt in Textform angezeigt werden soll, und ob dieser als Prozentzahl (<code>'percentage'</code> = 50%) oder als Anteil (<code>'fraction'</code> = 50/100) angezeigt werden soll. (Standard: <code>true</code>, <code>'percentage'</code>)</li>
<li><code>width</code> und <code>height</code>: Breite und Höhe des Fortschrittsbalkens bzw. der verwendeten Bilder.</li>
<li><code>callback</code>: Legt eine Funktion fest, welche aufgerufen wird, wenn sich der Balken bewegt. Die Funktion bekommt ein Argument mitgeliefert, welches das <code>config</code>-Feld, erweitert um die Werte <code>increment</code> (um wie viele Pixel hat sich der Balken bewegt), <code>running_value</code> (aktueller Wert) sowie <code>value</code> (Ziel-Wert).</li>
<li><code>boxImage</code>: Pfad zum Bild welches den Balken umschließt.</li>
<li><code>barImage</code>: Pfad zum inneren Bild des Balkens. Hier kann auch ein Feld übergeben werden, falls verschiedene Bilder verwendet werden sollen (siehe Beispiel).</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#fsb'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">progressBar</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">20</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
        boxImage<span style="color: #339933;">:</span> <span style="color: #3366CC;">'jquery.progressbar/images/progressbar.gif'</span><span style="color: #339933;">,</span>
        barImage<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #CC0000;">0</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'jquery.progressbar/images/progressbg_red.gif'</span><span style="color: #339933;">,</span>
            <span style="color: #CC0000;">30</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'jquery.progressbar/images/progressbg_orange.gif'</span><span style="color: #339933;">,</span>
            <span style="color: #CC0000;">50</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'jquery.progressbar/images/progressbg_yellow.gif'</span><span style="color: #339933;">,</span>
            <span style="color: #CC0000;">70</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'jquery.progressbar/images/progressbg_green.gif'</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h4>Methoden und Ereignisse</h4>
<p>Die Klasse bietet ein Ereignis (<code>callback</code>) und keine Methode. Will man den angezeigten Wert ändern, ruft man die Klasse einfach wieder wie folgt auf:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Aendere Wert auf 50%.</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#fsb'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">progressBar</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Prototype &#8211; jsProgressBarHandler</h3>
<p><a href="http://www.antusblog.de/wp-content/uploads/2009/07/Fortschrittsbalken.mit.Prototype.jsProgressBarHandler.png"><img src="http://www.antusblog.de/wp-content/uploads/2009/07/Fortschrittsbalken.mit.Prototype.jsProgressBarHandler.png" alt="Fortschrittsbalken mit Prototype jsProgressBarHandler" title="Fortschrittsbalken mit Prototype jsProgressBarHandler" width="500" height="100" class="aligncenter size-full wp-image-1828" /></a>Die <a href="http://www.bram.us/projects/js_bramus/jsprogressbarhandler/">jsProgressBarHandler</a>-Klasse basiert auf <a href="http://www.prototypejs.org/">Prototype</a> und steht unter der <a href="http://creativecommons.org/licenses/by-sa/2.5/">Creative Commons Attribution-Share Alike 2.5</a> Lizenz. Das tolle an dieser Klasse ist: Sie kann auch automatisch Fortschrittsbalken erstellen, alle <code>span</code>-Elemente mit der CSS-Klasse <code>progressBar</code>, die einen Prozentwert enthalten, werden automatisch zu Fortschrittsbalken umgewandelt. Der herkömmliche Weg über JavaScript funktioniert natürlich auch.</p>
<h4>Einbinden der Klasse</h4>
<p>Neben der Klasse selbst, muss auch die JavaScript-Bibliothek Prototype eingebunden werden.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js/prototype/prototype.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js/bramus/jsProgressBarHandler.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<h4>HTML</h4>
<p>Die Klasse wandelt alle span-Elemente mit der CSS-Klasse <code>progressBar</code> automatisch in Fortschrittsbalken um.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;progressBar&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fsb&quot;</span>&gt;</span>50%<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span></pre></div></div>

<p>Möchte man den Balken selbst mittels JavaScript erstellen, benötigt man ein <code>div</code>-Element mit einer ID.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fsb&quot;</span>&gt;</span>[Lade Fortschrittsbalken]<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<h4>Fortschrittsbalken erstellen</h4>
<p>Um den Balken selbst mittels JavaScript zu erstellen, muss man nur ein Objekt der Klasse <code>JS_BRAMUS.jsProgressBar</code> erstellen.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> fsb <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> JS_BRAMUS.<span style="color: #660066;">jsProgressBar</span><span style="color: #009900;">&#40;</span>
    <span style="color: #3366CC;">'fsb'</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// ID des div-Elements</span>
    <span style="color: #CC0000;">50</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// Ausgangswert (Prozent)</span>
    <span style="color: #009900;">&#123;</span>
        showText <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        animate <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        barImage <span style="color: #339933;">:</span> <span style="color: #3366CC;">'jsprogressbarhandler/images/bramus/percentImage_back1.png'</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Der dritte Parameter kann zur Konfiguration verwendet werden, und ist optional. Folgende Optionen gibt es:</p>
<ul>
<li><code>animate</code>: Ob der Fortschrittsbalken animiert sein soll. (Standard: ja)</li>
<li><code>showText</code>: Ob der Wert neben dem Balken angezeigt werden soll (Standard: ja)</li>
<li><code>width</code>: Breite des Balkens. Nicht vergessen: Das Bild muss ebenfalls angepasst werden. (Standard: 120)</li>
<li><code>boxImage</code>: Das Bild um den Balken.</li>
<li><code>barImage</code>: Der Hintergrund des Balkens. Hier kann auch ein Feld mit mehreren Bildern angegeben werden, dann ändert sich der Hintergrund, wenn der Balken weiter fortschreitet.</li>
<li><code>height</code>: Die Höhe des Balkens. (Standard: 12)</li>
<li><code>onTick</code>: Funktion die bei jeder Änderung am Wert des Balkens aufgerufen wird.</li>
</ul>
<p>Die Standardwerte sind am Anfang der <code>jsProgressBarHandler.js</code> definiert. Dort findet sich auch die Variable <code>autoHook</code>, diese kann man auf <code>false</code> setzen, wenn man nicht möchte, das alle <code>span.progressBar</code>-Elemente automatisch umgewandelt werden. Die Pfade zu den Bildern bzw. die Breite/Höhe will/muss man wahrscheinlich eh ändern.</p>
<h4>Methoden und Ereignisse</h4>
<p>Die Klasse hat zwei Funktionen und ein Ereignis, welches bei jeder Änderung am Wert aufgerufen wird (<code>onTick</code>). Mit der Funktion <code>getPercentage()</code> kann der aktuelle Wert abgefragt werden, mit <code>setPercentage()</code> kann der Wert verändert werden. Letztere Funktion akzeptiert zwei Parameter, der erste gibt den neuen Wert an, der zweite gibt an ob der Balken direkt zum neuen Wert gehen soll. Wenn man den Wert ändert, während der Balken sich noch bewegt, macht er normalerweise zuerst seine Bewegung zu Ende, bevor er zum neuen Wert geht, ist der zweite Parameter true, verwirft er alle anderen Bewegungen und bewegt sich direkt zum neuen Wert.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Wert abfragen</span>
<span style="color: #003366; font-weight: bold;">var</span> aktuellerWert <span style="color: #339933;">=</span> fsb.<span style="color: #660066;">getPercentage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// Wert aendern</span>
fsb.<span style="color: #660066;">setPercentage</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>mootools &#8211; dwProgressBar</h3>
<p><a href="http://www.antusblog.de/wp-content/uploads/2009/07/Fortschrittsbalken.mit.mootools.dwProgressBar.png"><img src="http://www.antusblog.de/wp-content/uploads/2009/07/Fortschrittsbalken.mit.mootools.dwProgressBar.png" alt="Fortschrittsbalken mit mootools - dwProgressBar" title="Fortschrittsbalken mit mootools - dwProgressBar" width="500" height="100" class="aligncenter size-full wp-image-1833" /></a>Die <code><a href="http://davidwalsh.name/dwprogressbar-2-stepping-events-mootools-progress-bar">dwProgressBar</a></code>-Klasse verfolgt einen etwas anderen Ansatz, als die vorigen beiden Klassen. Mit der Klasse können Fortschrittsbalken erstellt, und der angezeigte Wert geändert werden. Um die Animation kümmert sich die Klasse. Ansonsten können (müssen) die Fortschrittsbalken komplett selbst mittels CSS gestaltet werden. </p>
<h4>Einbinden der Klasse</h4>
<p>Die JavaScript-Bibliothek <a href="http://mootools.net/">mootools</a> wird vorausgesetzt. Außerdem muss natürlich die Klasse selbst eingebunden werden.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;mootools-1.2.3-core-yc.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dwprogressbar.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<h4>HTML und CSS</h4>
<p>Es wird nur ein div-Element benötigt.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;fsb&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>Die Gestaltung des Fortschrittsbalkens übernimmt die Klasse nicht, das muss man selber machen. Es gibt drei Elemente, die gestaltet werden können: Der Rahmen, der Balken, und der Text (optional). Beim Erstellen des Fortschrittsbalkens kann angegeben werden, welche ID die Elemente bekommen sollen, über die ID können die Elemente dann mittels CSS gestaltet werden. </p>
<h5>Ohne Bilder</h5>
<p>Die CSS-Selektoren für einen Fortschrittsbalken ohne Bilder (aber mit Text) könnten z.B. so aussehen:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#rahmen</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#8C2229</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span>inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#balken</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#8C2229</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#text</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span>inline-<span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h5>Mit Bildern</h5>
<p>Wenn man den Fortschrittsbalken mit Bildern gestalten möchte, kann man folgende CSS-Selektoren verwenden. Die Höhen- und Breitenangaben müssen natürlich angepasst werden.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#rahmen</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'rahmen.png'</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">right</span> <span style="color: #993333;">center</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#balken</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'balken.png'</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #993333;">center</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h4>Den Fortschrittsbalken erstellen</h4>
<p>Zum Erstellen des Fortschrittsbalkens wird einfach ein neues <code>dwProgressBar</code>-Objekt erstellt.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">window.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'domready'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> fsb <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> dwProgressBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// Das Element, in dem der Fortschrittsbalken angezeigt wird</span>
        container<span style="color: #339933;">:</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fortschrittsbalken'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">// Startwert (Prozent)</span>
        startPercentage<span style="color: #339933;">:</span> <span style="color: #CC0000;">50</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">// Geschwindigkeit/Dauer der Animation (in Millisekunden)</span>
        speed<span style="color: #339933;">:</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">// Die ID des Rahmens</span>
        boxID<span style="color: #339933;">:</span> <span style="color: #3366CC;">'rahmen'</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">// Die ID des Balkens</span>
        percentageID<span style="color: #339933;">:</span> <span style="color: #3366CC;">'balken'</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">// Wieviel Prozent pro Schritt (dwProgressBar.step() geht</span>
        <span style="color: #006600; font-style: italic;">// immer einen Schritt weiter, in diesem Beispiel also 10%.</span>
        step<span style="color: #339933;">:</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">// Erlaube Werte jenseits 100%</span>
        allowMore<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">// Prozentwert als Text anzeigen?</span>
        displayText<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">// ID für das Textelement</span>
        displayID<span style="color: #339933;">:</span> <span style="color: #3366CC;">'text'</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">// Ereignis, welches aufgerufen wird, wenn der Balken 100%</span>
        <span style="color: #006600; font-style: italic;">// erreicht.</span>
        onComplete<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Fertig!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #006600; font-style: italic;">// Ereignis welches nach jeder abgeschlossenen Änderung am</span>
        <span style="color: #006600; font-style: italic;">// Wert aufgerufen wird. (Wenn man von 10% auf 50% geht,</span>
        <span style="color: #006600; font-style: italic;">// wird es einmal aufgerufen, nämlich wenn 50% erreicht sind.)</span>
        onChange<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Wert geändert!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Es müssen nur die Optionen <code>container</code>, <code>boxID</code> und <code>percentageID</code> angegeben werden, der Rest ist optional.</p>
<h4>Funktionen und Ereignisse</h4>
<p>Die Klasse bietet die Funktionen <code>set(neuerwert)</code> und <code>step()</code>, außerdem die Ereignisse <code>onComplete</code> und <code>onChange</code>. Die Ereignisse sind im obigen Beispielquelltext bereits erklärt.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Wert auf 100% setzen</span>
fsb.<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// Einen Schritt weitergehen (um options.step Prozent)</span>
fsb.<span style="color: #660066;">step</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Zum Schluss noch einmal die Demo-Seite für die JavaScript-Fortschrittsbalken: <a href="/demos/8-fortschrittsbalken/jsbalken/fortschrittsbalken.html">Fortschrittsbalken-Demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.antusblog.de/2009/07/27/fortschrittsbalken-mit-cssjavascript/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Unbenutzte CSS-Selektoren finden mit Dust-Me Selectors</title>
		<link>http://www.antusblog.de/2009/04/05/unbenutzte-css-selektoren-finden-mit-dust-me-selectors/</link>
		<comments>http://www.antusblog.de/2009/04/05/unbenutzte-css-selektoren-finden-mit-dust-me-selectors/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 16:47:43 +0000</pubDate>
		<dc:creator>Antu</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Firefox-Erweiterung]]></category>
		<category><![CDATA[optimieren]]></category>
		<category><![CDATA[Selektoren]]></category>

		<guid isPermaLink="false">http://antusblog.de/?p=759</guid>
		<description><![CDATA[Wenn man nicht mehr benötigte HTML-Elemente entfernt oder CSS-Selektoren durch andere ersetzt kann es passieren das man vergisst die alten bzw. nicht mehr benötigten Selektoren aus der CSS-Datei zu entfernen. So sammeln sich über die Zeit immer mehr Selektoren an die gar nicht mehr benötigt werden und nur unnötig die CSS-Datei aufblähen. Mit der Firefox-Erweiterung [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://antusblog.de/wp-content/uploads/2009/04/unusedselectors.png"><img class="aligncenter size-full wp-image-765" title="Liste von unbenutzten CSS-Selektoren" src="http://antusblog.de/wp-content/uploads/2009/04/unusedselectors.png" alt="Liste von unbenutzten CSS-Selektoren" width="400" height="150" /></a></p>
<p>Wenn man nicht mehr benötigte HTML-Elemente entfernt oder CSS-Selektoren durch andere ersetzt kann es passieren das man vergisst die alten bzw. nicht mehr benötigten Selektoren aus der CSS-Datei zu entfernen. So sammeln sich über die Zeit immer mehr Selektoren an die gar nicht mehr benötigt werden und nur unnötig die CSS-Datei aufblähen. Mit der Firefox-Erweiterung <a href="http://www.sitepoint.com/dustmeselectors/" target="_blank">Dust-Me Selectors</a> lassen sich solche unbenutzten Selektoren sehr einfach aufspüren.</p>
<p><span id="more-759"></span></p>
<h2>Bedienung</h2>
<p>Nach der Installation der Erweiterung und dem obligatorischen Firefox-Neustart findet sich in der Statusleiste unten rechts ein kleiner pinker Staubwedel. Klickt man darauf wird die Überprüfung der geöffneten Seite gestartet. Nach ein paar Sekunden öffnet sich ein Ergebnis-Fenster in dem alle unbenutzten CSS-Selektoren inklusive der Zeile in der sie definiert sind angezeigt werden.</p>
<h3>Automatische Überprüfung</h3>
<p><a href="http://antusblog.de/wp-content/uploads/2009/04/menue.png"><img class="alignright size-full wp-image-776" title="Nach einem Rechtsklick auf den Staubwedel öffnet sich dieses Menü" src="http://antusblog.de/wp-content/uploads/2009/04/menue.png" alt="Nach einem Rechtsklick auf den Staubwedel öffnet sich dieses Menü" width="252" height="162" /></a>Meistens werden aber nicht alle Selektoren auf einer Seite benutzt, weswegen man mehrere HTML-Dateien überprüfen will. Hier gibt es zwei Möglichkeiten.</p>
<p>Die eine Möglichkeit besteht darin die automatische Überprüfung einzuschalten (Rechtsklick auf den Staubwedel, Automation-&gt;Run automatically) und alle Seiten die man überprüfen will anzusurfen.</p>
<p>Die andere Möglichkeit ist sogar noch einfacher, es wird allerdings eine Sitemap (Seite die Links zu allen zu überprüfenden Seiten enthält) benötigt. Hat man eine solche Sitemap, klickt man einfach auf Automation-&gt;Spider Sitemap, gibt dort die Adresse der Sitemap an und klickt auf Go. Dann werden automatisch alle in der Sitemap enthaltenen Links überprüft.</p>
<p>Ist die Überprüfung abgeschlossen öffnet sich ein Fenster welches die Ergebnisse anzeigt.</p>
<p><a href="http://antusblog.de/wp-content/uploads/2009/04/dustmeselectorsfenster.png"><img class="aligncenter size-full wp-image-770" title="Ergebnis-Fenster" src="http://antusblog.de/wp-content/uploads/2009/04/dustmeselectorsfenster.png" alt="Ergebnis-Fenster" width="460" height="480" /></a></p>
<p>Anhand der Ergebnisse ist es nun ein leichtes die entsprechenden CSS-Dateien von nicht mehr benötigten Selektoren zu befreien.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.antusblog.de/2009/04/05/unbenutzte-css-selektoren-finden-mit-dust-me-selectors/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

