Search Topic Here

Monday, 10 August 2015

Style Buttons with Bootstrap



Bootstrap has the following classes to style the buttons


.btn-default

.btn-primary

.btn-success

.btn-info

.btn-warning

.btn-danger

.btn-link





The classes that define the different sizes of the buttons  are:

.btn-lg

.btn-md

.btn-sm

.btn-xs



A button can be set to an active (appear pressed) or a disabled (unclickable) state:



The class .active makes a button appear pressed, and the class .disabled makes a button unclickable:



Example

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container" style ="background-color:white;">
  <h2>Button Styles</h2>
  <button type="button" class="btn btn-default">Default</button>
  <button type="button" class="btn btn-primary">Primary</button>
  <button type="button" class="btn btn-success">Success</button>
  <button type="button" class="btn btn-info">Info</button>
  <button type="button" class="btn btn-warning">Warning</button>
  <button type="button" class="btn btn-danger">Danger</button>
  <button type="button" class="btn btn-link">Link</button>    
  <br>
  <br>
  <br>
  <p>buttons with different sizes</p>

  <button type="button" class="btn btn-primary btn-lg">Large</button>
<button type="button" class="btn btn-primary btn-md">Medium</button>
<button type="button" class="btn btn-primary btn-sm">Small</button>
<button type="button" class="btn btn-primary btn-xs">XSmall</button>

<p>Active and disabled buttons</p>

<button type="button" class="btn btn-info active">Active Primary</button>
<button type="button" class="btn btn-info disabled">Disabled Primary</button>
 
</div>

</body>
</html>

output


Bootstrap Example

Button Styles




buttons with different sizes

Active and disabled buttons

No comments:

Post a Comment