本文介绍了如何在显示中获得相同的高度:table-cell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个按钮,我想要相同的height.Also我想要在标签分辨率相同的高度,我想这是在css实现。

I have 3 buttons and I want that to be of same height.Also I want that to be of same height in tab resolution as well.I want this to be achieved in css.

任何人都可以告诉我该如何实现。

Can anyone please tell me how can i achieve that.

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:

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

推荐答案

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;
}

模仿原始示例 p>

"to mimic the original example"

.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;
}

这篇关于如何在显示中获得相同的高度:table-cell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 10:28