Create a group of buttons that move vertically horizontally

I used the usual bootstrap button group in a column of size one, for example.

<div class="col-sm-1">
  <div class="btn-group">
    <button class="btn btn-default"><span class="glyphicon glyphicon-home"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-circle-arrow-left"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-volume-down"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-volume-up"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-off"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-zoom-out"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-zoom-in"></span></button>
  </div>
</div>

      

It's vertical when there is room, but when it drops to a new line, it becomes horizontal. My only problem is when the vertical looks a little weird. I've tried playing around with CSS to no avail, does anyone have any advice? I don't mind making it completely square, so the horizontal / vertical are similar, but my efforts to make it didn't work

improper horizontal alignment and corners

+3


source to share


2 answers


If all square buttons work for you, something like this should work:

CSS

#group button:first-child, #group button:last-child {
    border-radius: 0;
}
#group button:first-child {
    margin-left: -1px;
}

      



HTML:

<div class="col-sm-1">
  <div id="group" class="btn-group">
    <button class="btn btn-default"><span class="glyphicon glyphicon-home"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-circle-arrow-left"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-volume-down"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-volume-up"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-off"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-zoom-out"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-zoom-in"></span></button>
  </div>
</div>

      

+2


source


I've created something similar before.

DEMO: http://jsbin.com/vahaq/1/

Let's assume it is vertically 768px and up, which is, so I just changed the styles below this minimum width.

HTML (like yours, but with btn-group-vertical

and btn-group-custom

)



<div class="col-sm-1">
  <div class="btn-group-vertical btn-group-custom">
    <button class="btn btn-default"><span class="glyphicon glyphicon-home"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-circle-arrow-left"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-volume-down"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-volume-up"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-off"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-zoom-out"></span></button>
    <button class="btn btn-default"><span class="glyphicon glyphicon-zoom-in"></span></button>
  </div>
</div>  

      

This is a trickier task as it works and it works for really good responsiveness:

@media (max-width:299px) { 
    .btn-group-vertical.btn-group-custom > .btn {
        float: left;
        width: auto;
        width: 25%;
        min-height: 50px;
        min-width: 50px;
        margin-top: -1px!important;
    }
    .btn-group-vertical.btn-group-custom .btn + .btn {
        margin-left: -1px;
        margin-top: 0;
    }
    .btn-group-vertical.btn-group-custom > .btn:first-child {
        margin-top: 0;
        margin-left: -1px;
        border-radius: 0;
    }
    .btn-group-vertical.btn-group-custom > .btn:last-child {
        border-radius: 0
    }
}
@media (min-width:300px) and (max-width:767px) { 
    .btn-group-vertical.btn-group-custom > .btn {
        float: left;
        width: auto;
        border-top: 1px solid #ccc;
    }
    .btn-group-vertical.btn-group-custom .btn + .btn {
        margin-left: -1px;
        margin-top: 0;
    }
    .btn-group-vertical.btn-group-custom > .btn:first-child {
        border-radius: 4px 0 0 4px
    }
    .btn-group-vertical.btn-group-custom > .btn:last-child {
        border-radius: 0 4px 4px 0
    }
}

      

+2


source







All Articles