InterviewSolution
Saved Bookmarks
| 1. |
How to center Pills in Bootstrap? |
|
Answer» The .nav-justified class is used in Bootstrap to CENTER pills. The following is an example: <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Pills</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h3>Centered Pills</h3> <p><strong>Note:</strong> Resize the browser window to see the effect. Items LOOK stacked if the screen size if less than 768px</p> <ul class="nav nav-pills nav-justified"> <li class="ACTIVE"><a href="#">HOME</a></li> <li><a href="#">AboutUs</a></li> <li><a href="#">COMPANY</a></li> </ul> </div> </body> </html>The output when the screen size is less than 768px. The pills look stacked: The output when the screen size is more than 768px: |
|