Center any element in Bootstrap

BootstrapWeb DevelopmentCSS Framework

Use the .center-block class in Bootstrap to center an element.

You can try to run the following code to implement the .center-block class:

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <div class = "container">
         <h1>Heading One</h1>
         <div class = "center-block" style = "background-color:green;color: white; width:200px;">Text will be in center.</div>
      </div>
   </body>
</html>
raja
Published on 21-Jun-2018 11:38:21
Advertisements