1

I have <h1> and inside it <div class="pull-right"> which contains buttons at the same horizontal line with title of the site.

<div class="row">
    <div class="col-md-12">
        <h1>
            Title
            <div class="pull-right">
                <a href="#" class="btn btn-default">...</a>
                <a href="#" class="btn btn-default">...</a>
                <a href="#" class="btn btn-default">...</a>
            </div>
        </h1>
    </div>
</div>

Would it be possible to get the buttons below the title when using mobile devices? For example:

Example 1

lingo
  • 1,848
  • 6
  • 28
  • 56

4 Answers4

1

Don't do that because those buttons are not part of your title and this would have some SEO drawbacks (Search engines algorithms use contents of <h1> element as your first level heading on your page ). instead do this:

@media screen and (min-width: 1100px){ 
  .pull-right{
    display:inline-block;
  }
}
<div class="row">
    <div class="col-md-12">
        <h1>Title</h1><!--
        --><div class="pull-right">
            <a href="#" class="btn btn-default">...</a>
            <a href="#" class="btn btn-default">...</a>
            <a href="#" class="btn btn-default">...</a>
        </div>
    </div>
</div>

This way you have your desired output on mobile devices (Screen width lower than 1100px ) and inline state on devices width screen width higher than that

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
1

Firstly, you can't nest a div inside an h1. Secondly, why not use the grid system properly?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<div class="row">
  <div class="col-xs-12 col-md-6">
    <h1>Title</h1>
  </div>
  <div class="col-xs-12 col-md-6">
    <div class="pull-right">
      <a href="#" class="btn btn-default">...</a>
      <a href="#" class="btn btn-default">...</a>
      <a href="#" class="btn btn-default">...</a>
    </div>
  </div>
</div>
</div>
DavidG
  • 113,891
  • 12
  • 217
  • 223
0

You could wrap your heading inside a col-sm-12 col-md-5 .

THis would ensure that on small devices, the heading row takes the entire width, thush shifting the buttons below the title div.

For more information, see this : Responsive Grids: Bootstrap

code
  • 2,115
  • 1
  • 22
  • 46
0

Standart bootstrap disable pull-classes on mobile-view. You need manually add to your css next code:

@media(max-width:769px) {
  .pull-right {
     float:right!important;
  }
  .pull-left {
     float:left!important;
  }
}
Dmitriy Borisov
  • 598
  • 4
  • 8