Responsive Images In Bootstrap With Examples - C Programming Tutorial
C Course / Programs / Responsive Images In Bootstrap With Examples

Responsive Images In Bootstrap With Examples

BLUF: Understanding Responsive Images In Bootstrap With Examples is a foundational part of learning C programming. This tutorial explains the core principles and syntax needed to implement this concept effectively.
Core Programming Principle: Responsive Images In Bootstrap With Examples

C provides direct access to memory and system resources. Learn how Responsive Images In Bootstrap With Examples leverages this power in the lesson below.

The selection of image classes available in Bootstrap includes:

  1. .img-responsive class: In Bootstrap, responsive images are achieved by applying the .img-responsive class to the img element. This class sets the image to display as a block, with automatic height adjustment and a maximum width of 100%.

HTML Code:

Example

<!DOCTYPE html>
<html>
<head>
	<!-- Link Bootstrap CSS -->
	<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
	<!-- Link Bootstrap JS and JQuery -->
	<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">
		<h1>Responsive Image </h1>
		<br>
		<h3>.img-responsive class</h3>

<p>
			To see the effect, change the size of the browser window.
		</p>

		<img src=
"https://images.logic practice.com/images/logo/jtp_logo.png"
			class="img-responsive" alt="jtp_logo"
			width="307" height="240"/>
	</div>
</body>
</html>

Output:

Include the.img-fluid class within the tag to ensure the image is styled appropriately. This class sets the maximum width to 100% and adjusts the height automatically for responsive design.

HTML Code:

Example

<!DOCTYPE html>
<html>
<head>
	<!-- Link Bootstrap CSS -->
	<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
	<!-- Link Bootstrap JS and JQuery -->
	<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>.img-fluid class</h3>

<p>
		To see the effect, change the size of the browser window.
		</p>

		<img src=
"https://images.logic practice.com/images/logo/jtp_logo.png"
			class="img-fluid" alt="Responsive Image"
			width="307" height="240"/>
	</div>
</body>
</html>

Output:

Output

[Program Output]

The .img-rounded class applies circular borders to an image. (Internet Explorer 8 does not have compatibility for rounded corners.)

HTML Code:

Example

<!DOCTYPE html>
<html>
<head>
	<!-- Link Bootstrap CSS -->
	<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
	<!-- Link Bootstrap JS and JQuery -->
	<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>.img-rounded class</h3>

<p>Rounded Corners</p>

		<img src=
"https://img.freepik.com/free-psd/packaging-box-concept-mock-up_23-2148698796.jpg?w=2000"
			class="img-rounded" alt="Responsive Image"
			width="307" height="240"/>
	</div>
</body>
</html>

Output:

Output

[Program Output]

The

  1. .img-circle class modifies the image's shape to a circular form.

HTML Code:

Example

<!DOCTYPE html>
<html>
<head>
	<!-- Link Bootstrap CSS -->
	<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
	<!-- Link Bootstrap JS and JQuery -->
	<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>.img-circle class </h3>

<p>Circle</p>

		<img src=
"https://img.freepik.com/free-psd/packaging-box-concept-mock-up_23-2148698796.jpg?w=2000"
			class="img-circle" alt="Responsive Image"
			width="307" height="240"/>
	</div>
</body>
</html>

Output:

Output

[Program Output]

The .img-thumbnail class is utilized to convert the image into a thumbnail.

HTML Code:

Example

<!DOCTYPE html>
<html>
<head>
	<!-- Link Bootstrap CSS -->
	<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
	<!-- Link Bootstrap JS and JQuery -->
	<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>.img-thumbnail class</h3>

<p>Thumbnail</p>

		<img src=
"https://img.freepik.com/free-psd/packaging-box-concept-mock-up_23-2148698796.jpg?w=2000"
			class="img-thumbnail" alt="Responsive Image"
			width="307" height="240">
	</div>
</body>
</html>

Output:

Output

[Program Output]

Browsers that are supported:

  • Chrome by Google
  • Microsoft Internet Explorer
  • Safari
  • Firefox
  • Opera

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience