Open In App

How to place button in top Right corner using bootstrap?

Last Updated : 25 Jul, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

To place a button in the top right, there are several ways to do this.

  1. The easiest way to do this, Set “pull-right” in button class.
    Example:




    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
          place button in top right corner
      </title>
      
        <meta charset="utf-8">
        <meta name="viewport" 
              content="width=device-width, 
                       initial-scale=1">
        <link rel="stylesheet"
              href=
        
        <script src=
      </script>
        
        <script src=
      </script>
    </head>
      
    <body>
        <div class="container">
            <h1>
          <span style="color:green">GeeksforGeek</span>
          <button class='btn btn-success pull-right'>
            Button Text
              </button>
        </h1>
        </div>
    </body>
      
    </html>

    
    

    Output:

  2. The button group is used for more than one button like in this example.
    The button group is optional if you’re only using a single button.
    Example:




    <!DOCTYPE html>
    <html lang="en">
      
    <head>
        <title>
            place button in top right corner
        </title>
      
        <meta charset="utf-8">
        <meta name="viewport" 
              content="width=device-width, 
                       initial-scale=1">
        <link rel="stylesheet" 
              href=
      
        <script src=
        </script>
      
        <script src=
        </script>
    </head>
      
    <body>
      
        <div class="container">
            <section>
                <div class="page-header">
                    <h3 style="color:green"
                        class="pull-left">
            GeeksforGeeks
          </h3>
                    <div class="pull-right">
                        <div class="btn-group">
                            <button class="btn btn-success">
                                Languages
                            </button>
                            <button class="btn btn-success dropdown-toggle" 
                                    data-toggle="dropdown">
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu pull-right">
                                <li>
                                    <a href="#">DS</a>
                                </li>
                                <li>
                                    <a href="#">Python</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="clearfix"></div>
                </div>
                Other Content
            </section>
        </div>
    </body>
      
    </html>

    
    



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads