Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
960 views
in Technique[技术] by (71.8m points)

twitter bootstrap - First item in toggle button group with fixed width buttons taller

I have 5 items in a button group, when they are different widths (based on the text in each button) it works fine:

<div class="btn-group btn-group-toggle" data-toggle="buttons">
    <label class="btn btn-outline-primary btn-md active">
        <input type="radio" name="options" id="option1" checked> Strongly Disagree22222
    </label>
    <label class="btn btn-outline-primary btn-md">
        <input type="radio" name="options" id="option2"> Disagree
    </label>
    <label class="btn btn-outline-primary btn-md">
        <input type="radio" name="options" id="option3"> Unsure
    </label>
    <label class="btn btn-outline-primary btn-md">
        <input type="radio" name="options" id="option4"> Agree
    </label>
    <label class="btn btn-outline-primary btn-md">
        <input type="radio" name="options" id="option5"> Strongly Agree
    </label>
</div>

I'm trying to use 'btn-block' to make each button the same width, and it works for that, but the first item is taller.

How can I use btn-block to get this working, or how can I use a different method to get all the buttons to be the same width (ideally together taking up the full container width).[![enter image description here][2]][2]

<div class="btn-group btn-group-toggle" data-toggle="buttons">
    <label class="btn btn-outline-primary btn-block">
        <input type="radio" name="options" id="option1"> Strongly121212
    </label>
    <label class="btn btn-outline-primary btn-block">
        <input type="radio" name="options" id="option2"> Disagree
    </label>
    <label class="btn btn-outline-primary btn-block" active>
        <input type="radio" name="options" id="option3" checked> Unsure
    </label>
    <label class="btn btn-outline-primary btn-block">
        <input type="radio" name="options" id="option4"> Agree
    </label>
    <label class="btn btn-outline-primary btn-block">
        <input type="radio" name="options" id="option5"> Strongly Agree
    </label>
</div>

Note, I need these to be radio buttons. The user must be able to select 1 item (I like the outline with one selected solidly like in the example as it's obvious what's selected).

I found this, but it doesn't work for radio buttons, it's check boxes: btn-group create first button too hight

I spent many hours looking and could find nothing.

enter image description here

question from:https://stackoverflow.com/questions/65904831/first-item-in-toggle-button-group-with-fixed-width-buttons-taller

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...