Pavel Z.
Pavel Z.

Reputation: 45

Align elements inside fieldset

I tried different options in order to align elements inside a fieldset in order to keep both title, text and Learn More button on the same lines using different approaches. But the result was still negative: Align result

This is my code:

fieldset {
    height: 100%;
}
fieldset.scheduler-border {
    border: 2px solid #efefef !important;
    border-radius: 5px;
    padding: 0 1.4em 1.4em 1.4em !important;
    margin: 0 0 1.5em 0 !important;
    -webkit-box-shadow:  0px 0px 0px 0px #000;
            box-shadow:  0px 0px 0px 0px #000;
}

legend.scheduler-border {
    font-size: 0.7em !important;
    font-weight: bold !important;
    text-align: center !important;
    width:inherit; /* Or auto */
    padding:0 10px; /* To give a bit of padding on the left and right */
    border-bottom:none;
    vertical-align: sub;

}
.btn-devices{
    text-transform: none;
    background-color: #e64232;
    color: white;
}
<div class="col-md-4">
    <fieldset class="scheduler-border">
        <legend class="scheduler-border red">DEVICES</legend>
        <h3>ALL DEVICES SUPORTED</h3>
        <p class="desc-features">All our products are perfectly optimized for mobile, desktop and tablet.</p>
        <button type="button" class="btn btn-danger btn-devices">Learn More</button>
    </fieldset>
</div>

I would appreciate any possible suggestions, cause I did not find any help in information concerning this topic.

Upvotes: 1

Views: 1914

Answers (3)

JD Francis
JD Francis

Reputation: 494

I assume you mean center-aligned by your picture. By adding text-align:center to fieldset.scheduler-border you can achieve what you need.

Like this: http://jsfiddle.net/txdbsmdh/1/

EDIT: Ah, I see what you mean then. Well then the other responses are correct; there's not an "easy" way to do what you need. The easiest solution is to explicitly define the height of the elements above the buttons, either via min-height or height or by ensuring that the text is the same size. Unfortunately it's not a perfect solution and not a very responsive one. The only thing I can think of for a responsive solution (which I feel like you're looking for) is something along the lines of this: Make two parallel `<div>` colums the same height

Upvotes: 0

Rohit
Rohit

Reputation: 1812

As Paulie_D mentioned in the comment, there is no method for this but if suitable for you to define min-height then you can do the trick. Add min-height:100px for your description.

See fiddle: http://jsfiddle.net/txdbsmdh/2/

Upvotes: 1

vignesh
vignesh

Reputation: 1011

Check out what you expected

    <style type="text/css">
 fieldset
{
    height: 100%;
}
fieldset.scheduler-border {
    border: 2px solid #efefef !important;
    border-radius: 5px;
    padding: 0 1.4em 1.4em 1.4em !important;
    margin: 0 0 1.5em 0 !important;
    -webkit-box-shadow:  0px 0px 0px 0px #000;
            box-shadow:  0px 0px 0px 0px #000;
            display:table;
}

legend.scheduler-border {
    font-size: 0.7em !important;
    font-weight: bold !important;
    text-align: center !important;
    width:inherit; /* Or auto */
    padding:0 10px; /* To give a bit of padding on the left and right */
    border-bottom:none;
    vertical-align: sub;

}
.btn-devices{
    text-transform: none;
    background-color: #e64232;
    color: white;
}
.aligndiv {
        display: table-cell;
    vertical-align: middle;
    width: 250px;
    text-align: center
}

    </style>

<div class="col-md-4">
            <fieldset class="scheduler-border">
                <legend class="scheduler-border red">DEVICES</legend>
                <div class="aligndiv">
                    <h3>ALL DEVICES SUPORTED</h3>
                    <p class="desc-features">All our products are perfectly optimized for mobile, desktop and tablet.</p>
                    <button type="button" class="btn btn-danger btn-devices">Learn More</button>
                    </div>
            </fieldset>
        </div>

Upvotes: 0

Related Questions