如何在显示中获得相同的高度:table-cell

时间:2015-01-05 03:17:29

标签: html css

我有3个按钮,我希望它具有相同的高度。我也希望它在标签分辨率中具有相同的高度。我希望在css中实现这一点。

任何人都可以告诉我如何实现这一目标。

HTML:

<div class="content">
    <p>It's easy to become a member. </p>
    <p> Join today online    </p>
    <div class="btn-wrap">
        <div class="row">
            <div class="col"><a href="">Find Nearest Agent</a></div>
            <div class="col"><a href="" >Join Now</a></div>
            <div class="col"><a href="" >Download the App</a> </div>
        </div>
    </div>
</div>

CSS:

.content {
    width:75%; //there is a reason to use 75% here coz I have to place an image for remaining 25%.
}

.btn-wrap {
    display:table;
    border-collapse: separate;
    width:100%;
    overflow: hidden;
}

.row {
    display:table-row;
}

.col {
    display:table-cell;
    padding: 0 0.5% 0;
    width:32%;
    float: left;
} 

a {
    font-size: 20px;
}

input[type="submit"], a {
    border: 0 none;
    box-sizing: border-box;
    display: block;
    font-family: "Lato",Arial,sans-serif;
    font-size: 17px;
    font-style: normal;
    font-weight: 900;
    margin: 0;
    padding: 20px 10px;
    text-align: center;
    text-decoration: none;
    text-transform: uppercase;
    background-color: #ff0;
    color: #1d6221
}

的jsfiddle:http://jsfiddle.net/qwdduc7z/5/

2 个答案:

答案 0 :(得分:0)

<强> HTML

<div class="content">
    <p>Easy to become number</p>
    <p>Join Now </p>
    <div class="btn-wcircle-wrap">
        <div class="row">
            <a href="" class="col">Find Nearest Agent</a>
            <a href="" class="col btn yellow mt">Join Now</a>
            <a href="" class="col btn red mt">Download the App</a> 
        </div>
    </div>
</div>

<强> CSS

.content {
    width:75%;
}

.btn-wcircle-wrap {
    display: table;
    height: 100px;
}
.row {
    display: table-row;
}
.col {
    display: table-cell;
    padding: 0 0.5%;
    width: 32%;
} 
a {
    border: none;
    box-sizing: border-box;
    text-align: center;
    vertical-align: middle;
    font-family: "Lato",Arial,sans-serif;
    font-size: 17px;
    line-height: 1.5;
    font-style: normal;
    font-weight: 900;
    text-decoration: none;
    text-transform: uppercase;
    background-color: #ff0;
    color: #1d6221;
}

&#34;模仿原始示例&#34;

.content
{
    width:75%;
}
.btn-wcircle-wrap {
    display:table;
    width:100%;
}
.row {
    display:table-row;
}
.col {
    display:table-cell;
    padding: 20px 0.5%;
    width:32%;
    text-align: center;
    background-color: #ff0;
    box-shadow: 5px 0 0 0 white inset;
    // or use 
    // border: 5px solid white;
} 

a {
    box-sizing: border-box;
    vertical-align: text-top;
    font-family: "Lato",Arial,sans-serif;
    font-size: 17px;
    line-height: 1.5;
    font-style: normal;
    font-weight: 900;
    text-decoration: none;
    text-transform: uppercase;
    color: #1d6221;
}

http://jsfiddle.net/tksek87m/

答案 1 :(得分:0)

height: 75px;添加到input[type="submit"], a{。例如。 here