Skip to content Skip to sidebar Skip to footer

Css Table-cell Size - Conterintuitive Behaviour

Have a look to the following two images: Enabling or disabling the table-cell attribute discards the information about width and height. Actually I've them already disabled by the

Solution 1:

display:table-cell means that the div will take up the full width of the parent with either display:table-row or display:table unless shared with other "cells" and then the width will be split between them. You could make your .gold_button the table and the span the table-cell instead

.grey-footer-background {
    background-color: #a8a7a5;
    border-bottom: 1px black solid;
    padding: 10px0;
    width: 100%;
}
.gold_button {
    display: table;
    table-layout: fixed;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    font-weight: bold;
    text-align: center;
    border-right: solid 1px#262626;
    width: 80%;
    border: 1px solid black;
    margin: 0 auto;
    background-color:gold;
}
.gold_buttonspan {
    display: table-cell;
    vertical-align: middle !important;
    height: 60px;
}
<divclass="grey-footer-background"><divclass="gold_button"><span>Email</span></div></div>

Example

Solution 2:

Is this what you're looking for? (JSFiddle)

Adding:

line-height: desired height

should do it.

Post a Comment for "Css Table-cell Size - Conterintuitive Behaviour"