Bootstrap Responsive
Posted by Superadmin on April 30 2023 16:02:39

Bootstrap Responsive

By Priya PedamkarPriya Pedamkar
  

Bootstrap Responsive

Introduction to Bootstrap Responsive

Developing responsive websites is mandatory to present user requirements. People can access websites from anywhere and accessed them from different devices like mobile, PC, Notepad, etc. Even Google has considered a point of emphasizing how these responsive websites play an important role in web design. Designing or developing responsive websites from scratch becomes very difficult for beginners. So, Web developers come up with different technologies HTML5, CSS 3, and bootstrap. Among these 3, bootstraps are more responsive because of capable of dealing with jQuery, JavaFX, and CSS in a single bundle by including libraries. However, the people who aren’t ready to deal with cutting edge layout techniques still, the Bootstrap grid is providing an excellent opportunity alternatively.

What does “Responsive Bootstrap Website” Means?

Advantages of Bootstrap

How can we get a Responsive Website in Bootstrap?

1. While designing responsive pages in bootstrap, “Setting the Viewport” is important.

Syntax:

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

2. While designing responsive pages in bootstrap Media Queries, we can define different-different styles for different-different browser sizes.

Syntax:

@media screen and (min-width:value){
//CSS code
}

3. We have different HTML <picture> tag to allow different image sizes for different browsers.

Syntax:

<img class="img-responsive" src="imageName.jpg">

4. Include the bootstrap feature in our application; we must specify some pre-defined libraries inside our application. They are

<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

Examples of Bootstrap Responsive

Given below are the examples of Bootstrap Responsive:

Example #1

Responsive content example

Bootstrap Code: ResponsiveContent.html

<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Responsive</title>
<meta charset="utf-8">
<!-- makes responsive -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- including bootstrap css libraries -->
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<!-- including bootstrap JavaScript libraries -->
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- including bootstrap Popper libraries -->
<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<!-- including bootstrap libraries -->
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<!-- CSS styles -->
<style type="text/css">
h2
{
color:green;
}
h3
{
color:brown;
}
</style>
</head>
<body>
<div class="jumbotron text-center">
<!-- pre-defined class="jumbotron text-center gives text in the center -->
<h2>Bootstrap Responsive Demo</h2>
<h3>Even you can resize the page to see the text clearly.</h3>
</div>
<div class="container"> <!-- pre-defined class="container" gives proper text alignment at the sides -->
<div>
<span class="border">Executed and contributed to
full-stack web development projects, with an emphasis on front end
features, browser manipulation, and cross-browser compatibility.
Wrote templates and front-end code for ECM app to meet WebTop
application compatibility. Assisted in development of back end
features in Spring MVC with Hibernate. Developed importing models
and logic in Office Note app to store spreadsheet data and deployed
to host. </span><!-- pre-defined class="border" gives default border with black color -->
</div>
<br>
<div>
<span class="border border-success">Executed and contributed to
full-stack web development projects, with an emphasis on front end
features, browser manipulation, and cross-browser compatibility.
Wrote templates and front-end code for ECM app to meet WebTop
application compatibility. Assisted in development of back end
features in Spring MVC with Hibernate. Developed importing models
and logic in Office Note app to store spreadsheet data and deployed
to host. </span><!-- pre-defined class="border border-success" gives default border with green color -->
</div>
</div>
</body>
</html>

Output:

Screenshot #1

bootstrap responsive 1

Screenshot #2

bootstrap responsive 2

Screenshot #3

bootstrap responsive 3

Explanation:

Example #2

Responsive navigation example.

Bootstrap Code: ResponsiveNavigation.html

<!DOCTYPE html>
<html>
<head>
<title>Bootstrap Responsive</title>
<meta charset="utf-8">
<!-- makes responsive -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- including bootstrap jQuery libraries -->
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<!-- including bootstrap libraries -->
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<!-- including bootstrap libraries -->
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<!-- CSS styles -->
<style type="text/css">
h2 {
color: green;
}
h3 {
color: brown;
}
</style>
</head>
</head>
<body>
<nav class="navbar navbar-default">
<!--navbar navbar-default gives you white background with block color text navigation bar -->
<div class="container-fluid">
<!--container-fluid Gives you a full width container -->
<div class="navbar-header">
<!--navbar-header Gives you a navigation header -->
<a class="navbar-brand" href="https://www.educba.com/">EDUCBA
HOME</a>
<!-- navbar-brand used to set logo -->
</div>
<ul class="nav navbar-nav">
<!--nav navbar-nav used to sets the navigation bar size( either increase or reduce) -->
<!-- data-toggle="dropdown" gives drop-down list -->
<li class="dropdownList"><a class="dropdown-toggle"
data-toggle="dropdown" href="https://www.educba.com/tutorials/">EDUCBA
Courses <span class="caret"></span> <!-- class="caret" used to open drop down list -->
</a>
<ul class="dropdown-menu">
<!-- class="dropdown-menu" display drop down list values -->
<li><a
href="https://www.educba.com/category/software-development/software-development-tutorials/java-tutorial/">Java</a></li>
<li><a
href="https://www.educba.com/category/software-development/software-development-tutorials/python-tutorial/">Python</a></li>
<li><a
href="https://www.educba.com/category/software-development/software-development-tutorials/angular-tutorial/">Angular</a></li>
</ul></li>
<li><a href="https://www.facebook.com/">Facebook</a></li>
<li><a href="https://www.twitter.com/">Twitter</a></li>
<li><a href="https://www.youtube.com/">YouTube</a></li>
</ul>
</div>
</nav>
<div class="jumbotron text-center">
<!-- pre-defined class="jumbotron text-center gives text in the center -->
<h2>Bootstrap Responsive Demo</h2>
<h3>Even you can resize the page to see the navigation clearly.</h3>
</div>
</body>
</html>

Output:

Screenshot #1

Navigation.html

Screenshot #2

Navigation.html

Screenshot #3

bootstrap responsive 6

Explanation:

Example #3

Responsive image example.

Bootstrap Code: ResponsiveImage.html

<!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="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="jumbotron text-center">
<!-- pre-defined class="jumbotron text-center gives text in the center -->
<h2>Bootstrap Responsive Demo</h2>
<h3>Even you can resize the page to see the images clearly.</h3>
</div>
<div class="row">
<!-- puts all images in single row -->
<div class="col-md-4">
<!-- gives images to equal column size -->
<div class="thumbnail">
<!-- class="thumbnail" Adds 4 pixels of the padding and the gray border -->
<a href="1.jpg" target="_blank"> <img src="1.jpg" alt="Lights"
style="width: 100%"> <!-- target="_blank" which tells the browser to open a new window when we clicked -->
<div class="caption">
<!-- class="caption" gives caption -->
<p>Image 1</p>
</div>
</a>
</div>
</div>
<div class="col-md-4">
<div class="thumbnail">
<a href="2.jpg" target="_blank"> <img src="2.jpg" alt="Lights"
style="width: 100%">
<div class="caption">
<p>Image 1</p>
</div>
</a>
</div>
</div>
<div class="col-md-4">
<div class="thumbnail">
<a href="3.jpg" target="_blank"> <img src="3.jpg" alt="Lights"
style="width: 100%">
<div class="caption">
<p>Image 1</p>
</div>
</a>
</div>
</div>
</div>
</body>
</html>

Output:

Screenshot #1

Image.html

Screenshot #2

Image.html

Screenshot #3

bootstrap responsive 9

Explanation:

Conclusion

Bootstrap is a very flexible web technology to develop responsive pages in less time with its all predefined classes and libraries.