简体   繁体   中英

Distribute buttons (elements) evenly in columns

I have been trying to implement a keypad-like widget using bootstrap.

Here is a reconstruction of the problem at hand:

<div>
<div class="row">
    <span class="col-md-3">
        <button class="btn btn-lg btn-warning">1</button>
    <button class="btn btn-lg btn-warning">2</button>
    <button class="btn btn-lg btn-warning">3</button>
    </span>
    </div>

    <div class="row">
    <span class="col-md-3">
        <button class="btn btn-lg btn-warning btn-block">SPAN</button>
    </span>
    </div>
</div>

The problem with this is that the buttons labelled 1, 2 and 3 are not spread out evenly to fill the 3 column width parent.

Now, I do know there is the btn-group-justified class that I can use, but it stretches the buttons to fit the width of the parent. What I want is to add fillers between the buttons.

Can that be accomplished using Bootstrap or should I use display: table or some weird voodoo code involving margins.

How about a nested row?

http://jsfiddle.net/isherwood/XGb89/

<div class="row">
    <div class="col-md-3">
        <div class="row">
            <div class="col-xs-4 text-center">
                <button class="btn btn-lg btn-warning">1</button>
            </div>
            ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM