Casimyr: Problem mit Rahmen/Hintergrund

Hallo!

Ich habe wieder ein Problem.
Wie bekomme ich das weiße Rechteckt zwischen dem Rahmen und der Hintergrundfarbe vom <p> weg? Der Text soll dabei nicht verschoben werden, weshalb es mit padding nicht klappt.

<html>
<head>
<title>test</title>
<style>

div {
width:100;
padding:3px;
border: 1px solid yellow;
}

p {
background-color:yellow;
}

</style>
</head>
<body>
<div>
<p>test
</p>
</div>
</body>
</html>

So soll es am Ende aussehen:

<html>
<head>
<title>test</title>
</head>
<body>
<table width="100">
 <tr>
  <td style="background-color:yellow;padding:3px">test
  </td>
 <tr>
</body>
</html>

Nach einem Tipp hier aus dem Forum versuche ich <DIV>, statt Tabellen zu benutzen. Habe aber noch kleine Startprobleme. :)

Danke.

Casimyr

  1. Hallo!

    div.yellow {

    width:100;
    padding:3px;
    border: 1px solid yellow;

    background-color:yellow;

    }

    p {
    background-color:yellow;
    }

    </style>

    ...

    <div class="yellow">
      <p>Test</p>
    </div>

    fastix®

    1. Hallo,

      div.yellow {

      width:100;

      hier fehlt die Maßeinheit (Äpfel, Birnen) px oder pt oder cm usw.

      padding:3px;
      border: 1px solid yellow;
      background-color:yellow;
      }

      p {
      background-color:yellow;
      }

      </style>
      ...

      <div class="yellow">
        <p>Test</p>
      </div>

      Zur Ergänzung:
      Eine class macht dann Sinn, wenn es mehrere Elemente gibt, die jetzt und auch in der Zukunft gleich formatiert werden sollen, sonst ist es besser mit ids zu Arbeiten.

      cu,
      ziegenmelker

  2. Hallo,

    du kannst das alles auch ohne das div Element machen.

    p { width:100px; padding:3px; background-color:yellow }

    cu,
    ziegenmelker