Table of Contents
Bootstrap Image Classes: Styling and Usage Guide
Only Important Code
<div class="container"> <h2 id="article-heading-2">Rounded Corners</h2> <p>The .rounded class adds rounded corners to an image:</p> <img src="kingfisher.jpg" class="rounded" alt="Cinque Terre" width="304" height="236"> </div>
Full Code For The Above 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="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2 id="article-heading-4">Rounded Corners</h2>
<p>The .rounded class adds rounded corners to an image:</p>
<img src="kingfisher.jpg" class="rounded" alt="Cinque Terre" width="304" height="236">
</div>
</body>
</html>
See Live Preview of the above code
Only Important Code
<div class="container"> <h2 id="article-heading-6">Circle</h2> <p>The .rounded-circle class shapes the image to a circle:</p> <img src="pecock.jpg" class="rounded-circle" alt="Cinque Terre" width="304" height="236"> </div>
Full Code For The Above 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="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2 id="article-heading-8">Circle</h2>
<p>The .rounded-circle class shapes the image to a circle:</p>
<img src="pecock.jpg" class="rounded-circle" alt="Cinque Terre" width="304" height="236">
</div>
</body>
</html>
See Live Preview of the above code
Only Important Code
<div class="container"> <h2 id="article-heading-10">Thumbnail</h2> <p>The .img-thumbnail class creates a thumbnail of the image:</p> <img src="vogelbescherming.jpeg" class="img-thumbnail" alt="Cinque Terre" width="304" height="236"> </div>
Full Code For The Above 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="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2 id="article-heading-12">Thumbnail</h2>
<p>The .img-thumbnail class creates a thumbnail of the image:</p>
<img src="vogelbescherming.jpeg" class="img-thumbnail" alt="Cinque Terre" width="304" height="236">
</div>
</body>
</html>
See Live Preview of the above code
Only Important Code
<div class="container"> <h2 id="article-heading-14">Aligning images</h2> <p>Use the float classes to float the image to the left or to the right:</p> <img src="kingfisher.jpg" class="float-left" alt="Paris" width="304" height="236"> <img src="kingfisher.jpg" class="float-right" alt="Paris" width="304" height="236"> </div>
Full Code For The Above 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="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2 id="article-heading-16">Aligning images</h2>
<p>Use the float classes to float the image to the left or to the right:</p>
<img src="kingfisher.jpg" class="float-left" alt="Paris" width="304" height="236">
<img src="kingfisher.jpg" class="float-right" alt="Paris" width="304" height="236">
</div>
</body>
</html>
See Live Preview of the above code
Only Important Code
<div class="container"> <h2 id="article-heading-18">Centered Image</h2> <p>Center an image by adding the utility classes .mx-auto (margin:auto) and .d-block (display:block) to the image:</p> <img src="vogelbescherming.jpeg" class="mx-auto d-block" style="width:50%"> </div>
Full Code For The Above 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="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2 id="article-heading-20">Centered Image</h2>
<p>Center an image by adding the utility classes .mx-auto (margin:auto) and .d-block (display:block) to the image:</p>
<img src="vogelbescherming.jpeg" class="mx-auto d-block" style="width:50%">
</div>
</body>
</html>
See Live Preview of the above code
Only Important Code
<div class="container"> <h2 id="article-heading-22">Image</h2> <p>The .img-fluid class makes the image scale nicely to the parent element (resize the browser window to see the effect):</p> <img class="img-fluid" src="pecock.jpg" alt="Chania" width="460" height="345"> </div>
Full Code For The Above 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="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2 id="article-heading-24">Image</h2>
<p>The .img-fluid class makes the image scale nicely to the parent element (resize the browser window to see the effect):</p>
<img class="img-fluid" src="pecock.jpg" alt="Chania" width="460" height="345">
</div>
</body>
</html>
See Live Preview of the above code