Search code examples
htmlcsscounter

Center Counter Bootstrap Modal


I have a counter with increase decrease button. It's inside a model-content, but I can't center it in the middle of the modal. Can you help me?

https://i.sstatic.net/gkoMZ.png

    <div class="input-group" style="width:25%;">
        <span class="input-group-btn">
            <span class="btn btn-white btn-minuse" type="button">-</span>
        </span>
        <input type="text" class="form-control text-center height-25" value=0 >
        <span class="input-group-btn">
            <span class="btn btn-red btn-pluss" type="button">+</span>
        </span>
    </div>

Solution

  • To center it you should use margin: 0 auto. And that will solve your problem

    <div class="input-group" style="width:25%; margin: 0 auto;">
      <span class="input-group-btn">
                <span class="btn btn-white btn-minuse" type="button">-</span>
      </span>
      <input type="text" class="form-control text-center height-25" value=0>
      <span class="input-group-btn">
                <span class="btn btn-red btn-pluss" type="button">+</span>
      </span>
    </div>

    Also, avoid using Inline CSS styles. If that didn't help please let me know.