2016-11-24 2 views
0

테이블 행의 가운데에 헤더를 배치하는 방법은 무엇입니까?

.overzicht td{ 
 
    padding: 10px; 
 
    text-align: center; 
 
    max-width: 600px; 
 
    min-width: 600px; 
 
}
<table class='overzicht' border='1'> 
 
    <tr style='background-color: yellow;'> 
 
    <td colspan='9'> 
 
     <h2 style='margin-top: auto; '> Meest recente storing </h2> 
 
     <form method='POST' action='nieuwestoring.php' style='float: right; margin-bottom: 0px;'> 
 
     <input type='submit' style='padding: 10px;' name='nieuw' value='Nieuwe Storing'> 
 
     </form> 
 
    </td> 
 
    </tr> 
 
</table>

은 어떻게 버튼과 같은 높이에서 헤더 텍스트를 배치합니까? 버튼 위에 있지 않습니까?

+0

에 절대 위치를 적용 있나요? –

+0

.overzicht h2 { 디스플레이 : 인라인; } 또는 인라인 블록 ... – sinisake

+0

@AzeezKallayi 예! –

답변

2

이와 비슷한?

.overzicht td{ 
 
    padding: 10px; 
 
    text-align: center; 
 
    max-width: 600px; 
 
    min-width: 600px; 
 
} 
 

 
.overzicht h2 { 
 
    display:inline; 
 
    line-height: 39px; 
 
}
<table class='overzicht' border='1'> 
 
    <tr style='background-color: yellow;'> 
 
     <td colspan='9'> 
 
      <h2 style='margin-top: auto; '> Meest recente storing </h2> 
 
      <form method='POST' action='nieuwestoring.php' style='float: right; margin-bottom: 0px;'> 
 
       <input type='submit' style='padding: 10px;' name='nieuw' value='Nieuwe Storing'> 
 
      </form> 
 
     </td> 
 
    </tr> 
 
</table>

+1

또한'h2'가'button '과 수직으로 정렬되도록'margin-bottom : 0; line-height : 39px'를'h2'에 추가 할 수도 있습니다 –

+0

@Patrick 거의, 조금 더 낮은 pleasse –

+0

@ JelleBotman 답변을 다시 확인하십시오. 높이를 고정했습니다. –

0

마지막 통신을 기반으로이 코드

HTML

<table class='overzicht' border='1'> 
    <tr style='background-color: yellow;'> 
    <td><h2 style='margin-top: auto; '> Meest recente storing </h2></td> 
     <td> 
      <form method='POST' action='nieuwestoring.php' style='float: right; margin-bottom: 0px;'> 
       <input type='submit' style='padding: 10px;' name='nieuw' value='Nieuwe Storing'> 
      </form> 
     </td> 
    </tr> 
</table> 

CSS

table.overzicht{ 
     max-width: 600px; 
     min-width: 600px; 
     border-collapse: collapse; 
    } 
    .overzicht td{ 
     padding: 10px; 
     text-align: center; 
     vertical-align:center; 
     border:0px;  
    } 
    .overzicht td h2{ 
     margin: 0; 
    } 
+0

코드 스 니펫을 사용하여 직접 결과를 볼 수 있습니다. –

+0

이 링크를 참조하십시오 –

+0

https://jsfiddle.net/sonymathew/592Lqvuq/ –

0

을 시도하십시오 나는 패트릭의 대답 업데이트 ENT

I 버튼

이 같은 줄에 제목과 버튼을 만들고 싶어

.overzicht td{ 
 
    padding: 10px; 
 
    text-align: center; 
 
    max-width: 600px; 
 
    min-width: 600px; 
 

 
position: relative; 
 
} 
 

 
.overzicht h2 { 
 
    display:inline; 
 
    line-height: 39px; 
 
} 
 
form{ 
 
    position: absolute; 
 
    right: 10px; 
 
    top: 10px; 
 
}
<table class='overzicht' border='1'> 
 
    <tr style='background-color: yellow;'> 
 
     <td colspan='9'> 
 
      <h2 style='margin-top: auto; '> Meest recente storing </h2> 
 
      <form method='POST' action='nieuwestoring.php' style='margin-bottom: 0px;'> 
 
       <input type='submit' style='padding: 10px;' name='nieuw' value='Nieuwe Storing'> 
 
      </form> 
 
     </td> 
 
    </tr> 
 
</table>

관련 문제