Bootstrap button block example

Hi Friends 👋,

Welcome To aGuideHub! ❤️

To make a button block, put the .btn-block" class in an button block it will show the block.

Today, I am going to show you. How to create button block in bootstrap 4 with code example.

In many websites, we notice that there are big block level buttons used to perform some work when the user clicks on them.

The btn class followed by contextual classes is used to create buttons on the website.

Here, we will use .btn-block class to make a block button in bootstrap.

Table of contents

  • Includes bootstrap view
  • Includes bootstrap library
  • Define its class name

This article will guide you to adding button block in Bootstrap with example.

Step 1: Includes bootstrap view

To ensure proper rendering and touch zooming for all devices, add the responsive viewport meta tag to your <head>.

    <meta name="viewport" content="width=device-width, initial-scale=1">

Step 2: Includes bootstrap library

First of all, load the Bootstrap framework CSS into the head tag of your webpage.

<!-- Bootstrap CSS -->
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/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/4.1.3/js/bootstrap.min.js">
    </script>

Step 3: Define its class name

We will add the type as button and add classes btn, btn-danger, btn-lg and btn-block. We will then write the text that will be seen on the button.

    <button type="button" class="btn btn-danger
				btn-lg btn-block">
		Click Here
	</button>

Example.

Let’s look at the following example to understand how it basically works:

<!DOCTYPE html>
<html>

<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/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/4.1.3/js/bootstrap.min.js">
    </script>
</head>

<body>
    <h2 class="text-center">aGuideHub</h2>
    <br><br>
    <div class="text-center">Block Button</div>
    <br><br>
    <button type="button" class="btn btn-danger
				btn-lg btn-block">
		Click Here
	</button>
</body>

</html>

Check the output of the above code example.

Bootstrap, Block-button

All the best 👍

Premium Content

You can get all the below premium content directly in your mail when you subscribe us

Books

Interview Questions

Soon You will get CSS, JavaScript, React Js, and TypeScript So Subscribe to it.

Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

Related Posts