2016-10-31 8 views
0

Bitte helfen Sie mir, mein Bild neben den Tasten auszurichten. Ich möchte auch die Tasten auf der jeweils anderen, aber esWie kann ich vertikale Schaltflächen neben dem Bild ausrichten?

.body{ 
 
    background-color:#dbdbdb; 
 
} 
 
button{ 
 
    width:200px; 
 
    height:60px; 
 
    margin-right:10px; 
 
    
 
}
</div> 
 
<div class="body"> 
 
    <table> 
 
    <tr> 
 
     <td><img id="business"src="http://fullhdpictures.com/wp-content/uploads/2016/08/Business-People-Photos-HD.jpg"/></td> 
 
     <td> <button id="plan" type="button">PLANNING</button></td> 
 
     <td> <button id="strat" type="button">STRATEGY</button></td> 
 
     <td> <button id="res" type="button">RESULTS</button></td> 
 
    </tr> 
 
    </table> 
 
    
 
</div>

enter image description here

+6

Das ''

Element ist es * Tabellendaten * angezeigt werden, nicht ein Bild neben einem Navigationsmenü. –

+0

Können Sie ein Bild mit dem erwarteten Ergebnis hinzufügen? –

Antwort

0

.body{ 
 
    background-color:#dbdbdb; 
 
} 
 
button{ 
 
    width:200px; 
 
    height:60px; 
 
    margin-right:10px; 
 
    
 
} 
 
td { 
 
    vertical-align:middle; 
 
}
</div> 
 
<div class="body"> 
 
    <table> 
 
    <tr> 
 
     <td><img id="business"src="http://fullhdpictures.com/wp-content/uploads/2016/08/Business-People-Photos-HD.jpg"/></td> 
 
     <td> 
 
     <div> 
 
      <button id="plan" type="button">PLANNING</button> 
 
      <button id="strat" type="button">STRATEGY</button> 
 
      <button id="res" type="button">RESULTS</button> 
 
     </div> 
 
     </td> 
 
    </tr> 
 
    </table> 
 
    
 
</div>

0

Nehmen Sie aus Tisch neben dem Bild sitzen machen und die nav Elemente in einem div setzen mit der gleichen Höhe wie das Bild und setzen Sie eine vertikale Ausrichtung: Mitte; dies wird das Element in der Mitte des Mutter div Element

0

Fügen Sie diese in Ihrem Stylesheet setzen:

Table td 
{ 
Verticale-align: middle; 
} 
0

können Sie vertikal ausrichten versuchen: top

Beispiel:

.body{ 
 
    background-color:#dbdbdb; 
 
} 
 
button{ 
 
    width:200px; 
 
    height:60px; 
 
    margin-right:10px; 
 
    
 
}
<div class="body"> 
 
    <table> 
 
    <tr> 
 
     <td><img id="business"src="http://fullhdpictures.com/wp-content/uploads/2016/08/Business-People-Photos-HD.jpg"/></td> 
 
     <td style="vertical-align:top;"> <button id="plan" type="button">PLANNING</button></td> 
 
     <td style="vertical-align:top;"> <button id="strat" type="button">STRATEGY</button></td> 
 
     <td style="vertical-align:top;"> <button id="res" type="button">RESULTS</button></td> 
 
    </tr> 
 
    </table> 
 
    
 
</div>

3

Verwenden flexbox, weniger Markup, eine bessere Flexibilität und semantisch richtiger als table

.body { 
 
    display: flex; 
 
} 
 
.body > div { 
 
    display: flex; 
 
    flex-direction: column; 
 
    justify-content: center; 
 
} 
 

 
button { 
 
    width: 200px; 
 
    height: 60px; 
 
    margin-right: 10px; 
 
} 
 

 

 
/* for demo purpose I made image smaller so one can see the layout */ 
 
.body > img { 
 
    display: block; 
 
    width: 420px; 
 
    height: 276px; 
 
}
<div class="body"> 
 
    <img id="business" src="http://fullhdpictures.com/wp-content/uploads/2016/08/Business-People-Photos-HD.jpg" /> 
 
    <div> 
 
    <button id="plan" type="button">PLANNING</button> 
 
    <button id="strat" type="button">STRATEGY</button> 
 
    <button id="res" type="button">RESULTS</button> 
 
    </div> 
 
</div>

+0

Ich habe dies versucht und die Tasten ausgerichtet, aber das Bild wurde gestreckt. – TGIM0791

+0

@ TGIM0791 Dann hast du etwas verpasst, während du meinen Code kopierst, poste es und ich werde ... schauen, da 'table' nicht wirklich der richtige Weg ist, aber es ist dein Anruf – LGSon

0
#plan { 
    background-color: #B21589; 
    cursor: pointer; 
    color: white; 
    font-size: 9px; 
    font-weight: bold; 
    padding: 4px; 
    margin-top: 2px; 
    vertical-align: top; 
} 

Link: - Alignment of Buttons Next to Images

Verwandte Themen