Ankündigung

Einklappen
Keine Ankündigung bisher.

[Erledigt] Buttons in Banner

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • [Erledigt] Buttons in Banner

    Hallo,

    ich beschäftige mich erstmals mit CSS und habe deswegen nicht so viel Ahnung, wie alles geht.

    Ich habe einen Banner als Bild mit der Höhe von 36px.
    Zwei Buttons sollen genau auf dem Banner liegen, was sie momentan noch nicht tun, da sie ein paar Pixel darüber liegen.
    Wo liegt der Fehler, ihr könnt mir sicher helfen.

    PHP-Code:
    <style type="text/css">

    a.button {
     
    font-family:Lucida Bright;
     
    font-size:14px;
     
    font-weight: 500;
     
    color: #E27100;
     
    background-color: #7C7C7C;
     
    border-left: 0px solid #CCCCCC;
     
    border-top: 2px solid #7C7C7C;
     
    border-right: 2px solid #7C7C7C;
     
    border-bottom: 0px solid #606060;
     
    text-decoration: none;
     
    padding: 9px;
     
    text-align: center;
    }

    a.button:hover {
     
    color: #000000;
     
    background-color: #FF954F;
     
    border-left: 2px solid #3F3F3F;
     
    border-top: 2px solid #3F3F3F;
     
    border-right: 0px solid #cccccc;
     
    border-bottom: 0px solid #606060;
     
    text-decoration: none;
    }

    .
    headbanner {
     
    background:url(layout/headbanner.png);
     
    border:2px solid #000000;
     
    background-repeat:no-repeat;
     
    height:100%;
     }

    </
    style>

    <
    br />
    <
    div class="headbanner">
     <
    center>
     <
    div style="border:2px solid red; margin-top:0px; margin-bottom:0px; padding-top:0px;">
     <
    a href="#" class="button">Bilder</a>&nbsp;
     <
    a href="#" class="button">Kontakt</a>&nbsp;
     <
    a href="#" class="button">Links</a>
     </
    center>
     </
    div>

    </
    div> 
    Die Rahmenlinien habe ich nur für mich zum Erkennen hingemacht.

    Gruß

  • #2
    Stichwort position: absolute;

    Kommentar


    • #3
      Das geht auch mit position:relative;
      Ich sehe du hast keine Höhe für den Banner definiert. Tu es lieber explizit mit der von dir angegebenen Höhe. Außerdem solltest du ein CSS-Reset nutzen, da jeder Browser eigene Abstände an verschiedene Elemente setzt.
      PS: Verzichte im Markup auf Stilistische Definitionen (oder anders gesagt: Lass das <center>-Tag weg).

      Kommentar


      • #4
        Ich habs jetzt nochmal bisschen umgeändert, komm aber einfach nicht zum Ergebnis.
        Mit position:absolute bzw. relative funktioniert es einfach nicht.

        So siehts momentan aus.
        PHP-Code:
        <style type="text/css">

        a.button {
         
        font-family:Lucida Bright;
         
        font-size:14px;
         
        font-weight: 500;
         
        color: #E27100;
         
        background-color: #7C7C7C;
         
        border-left: 0px solid #CCCCCC;
         
        border-top: 2px solid #7C7C7C;
         
        border-right: 2px solid #7C7C7C;
         
        border-bottom: 0px solid #606060;
         
        text-decoration: none;
         
        padding: 9px;
         
        text-align: center;
        }

        a.button:hover {
         
        color: #000000;
         
        background-color: #FF954F;
         
        border-left: 2px solid #3F3F3F;
         
        border-top: 2px solid #3F3F3F;
         
        border-right: 0px solid #cccccc;
         
        border-bottom: 0px solid #606060;
         
        text-decoration: none;
        }

        .
        headbanner {
         
        background:url(layout/headbanner.png);
         
        border:2px solid #000000;
         
        background-repeat:no-repeat;
         
        height:36px;
         
        position:relative;
         
        top:1px;
         }

        </
        style>

        <
        br />
        <
        div class="headbanner">


         <
        a href="#" class="button">Bilder</a>&nbsp;
         <
        a href="#" class="button">Kontakt</a>&nbsp;
         <
        a href="#" class="button">Links</a>

        </
        div> 
        Bräuchte nochmal paar Tipps, krieg das einfach nicht hin

        Kommentar


        • #5
          Lad dein Werk mal auf jsFiddle hoch, on the fly ist sowas immer einfach einzusehen.

          Kommentar


          • #6
            Wofür ist das gut?

            [http://jsfiddle.net/hZGbN/]

            Kommentar


            • #7
              Damit wir deinen Code live nachvollziehen können.

              a.button benötigt noch
              display: inline-block;

              Edit: Nimm doch lieber eine unsortierte Liste:
              http://jsfiddle.net/SJ7PH/

              Kommentar


              • #8
                Hab jetzt bisschen die Größe verändert und jetzt passt das ungefähr.

                Ich habe den vertical-align vom Button hinzugefügt und bei headbanner habe ich den Oberrand auf 1px gemacht und die gleiche Farbe wie der Hintergrund des Bilds genommen.

                So passt das, unten fehlt ein Pixel, fällt aber eigentlich kaum auf.

                PHP-Code:
                <style type="text/css">

                a.button {
                 
                font-family:Lucida Bright;
                 
                font-size:14px;
                 
                font-weight: 500;
                 
                color: #E27100;
                 
                background-color: #7C7C7C;
                 
                border-left: 0px solid #CCCCCC;
                 
                border-top: 2px solid #7C7C7C;
                 
                border-right: 2px solid #7C7C7C;
                 
                border-bottom: 0px solid #606060;
                 
                text-decoration: none;
                 
                padding: 9px;
                 
                text-align: center;
                 
                vertical-align:sub;

                }

                a.button:hover {
                 
                color: #000000;
                 
                background-color: #FF954F;
                 
                border-left: 2px solid #3F3F3F;
                 
                border-top: 2px solid #3F3F3F;
                 
                border-right: 0px solid #cccccc;
                 
                border-bottom: 0px solid #606060;
                 
                text-decoration: none;
                }

                .
                headbanner {
                 
                background:url(layout/headbanner.png);
                 
                border-top:1px solid #FF9700;
                 
                background-repeat:no-repeat;
                 
                height:36px;
                 
                position:relative;
                 
                top:1px;
                 }

                </
                style>

                <
                br />
                <
                div class="headbanner">


                 <
                a href="#" class="button">Bilder</a>&nbsp;
                 <
                a href="#" class="button">Kontakt</a>&nbsp;
                 <
                a href="#" class="button">Links</a>



                </
                div>
                <
                br /><br />
                <
                br /><a href=""> 
                Gruß und Danke!

                Kommentar


                • #9
                  Habe nochmal rumprobiert und falls jemand das jetzt braucht, hier nochmal der CSS-Teil:

                  PHP-Code:
                  <style type="text/css">
                  a.button {
                   
                  font-family:Lucida Bright;
                   
                  font-size:14px;
                   
                  font-weight: 500;
                   
                  background:url(headbanner.png);
                   
                  color: #000000;
                   // background-color: #7C7C7C;
                   
                  border-left: 0px solid #CCCCCC;
                   
                  border-top: 0px solid #7C7C7C;
                   
                  border-right: 0px solid #7C7C7C;
                   
                  border-bottom: 0px solid #606060;
                   
                  text-decoration: none;
                   
                  padding: 9px;
                   
                  vertical-align:middle;
                   
                  text-align:center;
                   
                  line-height: 36px;

                  }

                  a.button:hover {
                   
                  color: #000000;
                   
                  background:url(hover.png);
                   
                  height:100%;
                   
                  border-left: 0px solid #D16F00;
                   
                  border-top: 0px solid #E17900;
                   
                  border-right: 0px solid #cccccc;
                   
                  border-bottom: 0px solid #854200;
                   
                  text-decoration: none;
                   
                  vertical-align:middle;
                   
                  text-align:center;
                   
                  line-height: 36px; 
                  }

                  .
                  headbanner {
                   
                  background:url(headbanner.png);
                   
                  border-top:0px solid #FF9700;
                   
                  background-repeat:x;
                   
                  height:36px;
                   
                  witdh:100%;
                   
                  position:relative;
                   
                  top:1px;
                   
                  margin-top:0px;
                   }

                  </
                  style> 
                  Gruß

                  Kommentar

                  Lädt...
                  X