Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to a make a Bootstrap button full width?

This is what I have right now. I can't get it to become full width

Almost full width

This is the html. I've already tried adding .btn-block class but I get the same results as if I just used width: 100%; in the css. Maybe the problem is with the parent element?

<article class="col-xs-12 col-md-4">
            <div class="label label-success price"><span class="glyphicon glyphicon-tag"></span>$39</div>

            <div class="price-title">
                <h3>LOREM</h3>

                <small>Lorem Ipsum</small>
            </div>

            <div class="price-content ">
                <ul>
                    <li><h4>Item or Service # 1</h4></li>
                    <li><h4>Item or Service # 2</h4></li>
                    <li><h4>Item or Service # 3</h4></li>
                    <li><h4>Item or Service # 4</h4></li>
                    <li><h4>Item or Service # 5</h4></li>
                    <li><h4>Item or Service # 6</h4></li>
                </ul>

                <a href="#"><div class="btn btn-success">Sign Up</div></a>
            </div>
        </article>

And these are the styles

#tables{
color: white;
text-align: center;
margin: 15px 20px;}


.price{
position: relative;
top: 20px;
font-size: 30px;}

.price-content{
background-color: #E8E9EA;
color: #69696A;
padding-right: 50px;
padding-top: 30px;
height: 350px;
margin-bottom: 80px;
width: 100%;}

.btn{
border-radius: 0px;
font-size: 20px;
font-weight: bold;
width: 100%;}
like image 291
Andrés Liu Avatar asked Jun 19 '15 01:06

Andrés Liu


People also ask

How can set full width button in Bootstrap?

Add .btn-lg or .btn-sm for additional sizes. Create block level buttons—those that span the full width of a parent—by adding .btn-block .

How do you make a button full width?

display: block and width: 100% is the correct way to go full width but you need to remove the left/right margin on the button as it pushes it outside the containing element. for more information on the box-sizing property, read the MDN docs.


1 Answers

Well first question... why the heck are you nesting a div inside the a tag? <a href="#"><div class="btn btn-success">Sign Up</div></a>. Try this:

<a class="btn btn-block btn-success" href="#">Sign Up</a>

Then remove padding-right: 50px; from the .price-content selector.

like image 150
Sean Stopnik Avatar answered Oct 15 '22 20:10

Sean Stopnik