CSS: Unterschied zwischen den Versionen

Aus Vokabulabor
Zur Navigation springen Zur Suche springen
Zeile 10: Zeile 10:
* Datei anlegen: index.html
* Datei anlegen: index.html
<pre>
<pre>
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
Zeile 16: Zeile 16:
</head>
</head>
<body>
<body>
   <h1>Try it!</h1>
   <div class="sheet">
  <div class="region1">
    <h1>Try it!</h1>
    This is a paragraph.
    <div class="region1 right">
  </div>
      This is a paragraph with right alignment.
  <div class="region2">
    </div>
    <div class="error">Error found</div>
    <div class="region2">
    <div class="warning">Warning: it is dangerous</div>
      <div class="error">Error found</div>
  </div>
      <div class="warning">Warning: it is dangerous</div>
  <div class="region1">
    </div>
    This is a paragraph too.
    <div class="region1 middle">
   </div>
      This is a paragraph too, but with center alignment.
    </div>
   <div>
</body>
</body>
</html>  
</html>
</pre>
</pre>
* Datei anlegen: tutorial.css
* Datei anlegen: tutorial.css
<pre>
<pre>
body {
h1, h2, h3 {
   background-color: lightgrey;
  border-bottom: 1px blue solid;
}
.sheet {
   background-color: #cc;
  margin: 1em;
  padding: 1em;
}
}
.region1 {
.region1 {
Zeile 41: Zeile 48:
.region2 {
.region2 {
   background-color: white;
   background-color: white;
  margin: 2em 3em 2em 1em;
}
}
.error {
.error {
   color: red;
   color: red;
   padding: 1em;
   border: 0.1em solid red;
}
}
.warning {
.warning {
   color: blue;
   color: blue;
   padding 2em;
}
.middle {
   text-align: center;
}
.right {
  text-align: right;
}
}
</pre>
</pre>
* Datei index.php im Browser öffnen.
* Datei index.php im Browser öffnen.

Version vom 19. September 2023, 17:49 Uhr

Links

Zielsetzung

Cascading Style Sheets (CSS) ist eine Sprache, mit der HTML-Inhalte mit Formateigenschaften ausgestattet werden. Das dient der Trennung von Inhalt (HTML) und Form (CSS).

Schnellkurs

  • Datei anlegen: index.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="tutorial.css">
</head>
<body>
  <div class="sheet">
    <h1>Try it!</h1>
    <div class="region1 right">
       This is a paragraph with right alignment.
    </div>
    <div class="region2">
       <div class="error">Error found</div>
       <div class="warning">Warning: it is dangerous</div>
    </div>
    <div class="region1 middle">
       This is a paragraph too, but with center alignment.
    </div>
  <div>
</body>
</html>
  • Datei anlegen: tutorial.css
h1, h2, h3 {
  border-bottom: 1px blue solid;
}
.sheet {
  background-color: #cc;
  margin: 1em;
  padding: 1em;
}
.region1 {
  background-color: lightgreen;
  margin: 1em 33%;
}
.region2 {
  background-color: white;
}
.error {
  color: red;
  border: 0.1em solid red;
}
.warning {
  color: blue;
}
.middle {
  text-align: center;
}
.right {
  text-align: right;
}
  • Datei index.php im Browser öffnen.