How to set div with left image and button at bottom using bootstrap?
Last Updated :
05 May, 2022
We can set div with left image and button at the bottom by two methods as follows:
Method 1: Using bootstrap
Float-left
These utility classes float-left a component to the left or disable floating, based on the current viewport size utilizing the CSS float property. !important is included to dodge (avoid) specificity issues. These utilize the same viewport breakpoints as our grid system.
Position-relative:
It is same as CSS property position: relative.
Position-absolute:
It is same as CSS property position: absolute.
Example:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,
initial-scale=1, shrink-to-fit=no"/>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
integrity=
"sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk"
crossorigin="anonymous"/>
<script src=
"https://kit.fontawesome.com/577845f6a5.js"
crossorigin="anonymous">
</script>
<title>Set div with left image
</title>
<style type="text/css">
.bottom-left {
left: 0;
}
</style>
</head>
<body>
<h1 style="color: #006400;">
<br/>
GeeksforGeeks
</h1>
<div class="float-left">
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200712114621/testimg.JPG"
height="150"/>
</div>
<div class="position-relative" style="color: green;">
<h1>Hey There..!!</h1>
<p><b>This is an Example..</b></p>
<p>Here I have used class float-left of
bootstrap to set div with left image.</p>
<br/>
</div>
<div class="position-relative">
<div class="position-absolute bottom-left">
<button type="button"
class="btn btn-success">
Click me!
</button>
</div>
</div>
</body>
</html>
Output:

Note: If your content is less then kindly place <br> tag at end of content or else button will misplace as it is position-relative to content.
Using bootstrap 3 we can set div with left image & button at the bottom and right image & button at the bottom by a bootstrap grid system too as follows:
Example:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,
initial-scale=1, shrink-to-fit=no"/>
<!-- Bootstrap CSS -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity=
"sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous"/>
<!-- Optional theme -->
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css"
integrity=
"sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp"
crossorigin="anonymous" />
<!-- Latest compiled and minified JavaScript -->
<script src=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
integrity=
"sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous">
</script>
<title>Set div with left image</title>
<style type="text/css">
.bottom-left {
left: 0;
}
.bottom-right {
right: 0;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="col-md-6">
<div class="pull-right">
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200712114621/testimg.JPG"
height="150" />
</div>
<div style="color: green; text-align: left;">
<h1>Hey There..!!</h1>
<p><b>This is an Example..</b></p>
<p>Here I have used class pull-right of
bootstrap to set div with right image.
</p>
<br/>
<br/>
</div>
<div class="pull-right bottom-right">
<button type="button" class="btn btn-success">
Click me!
</button>
</div>
</div>
<div class="col-md-6">
<div class="pull-left">
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200712114621/testimg.JPG"
height="150" />
</div>
<div style="color: green;
text-align: right;">
<h1>Hey There..!!</h1>
<p><b>This is an Example..</b></p>
<p>
Here I have used class pull-left of
bootstrap to set div with left image.
</p>
<br/>
<br/>
</div>
<div class="pull-left bottom-left">
<button type="button"
class="btn btn-success">
Click me!
</button>
</div>
</div>
</div>
</body>
</html>
Output:

Note: Due to the bootstrap grid system output will look different when code will be run on IDE hence run this code on your source.
Method 2: Using Flexbox
Example:
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,
initial-scale=1, shrink-to-fit=no" />
<title>Set div with left image</title>
<style type="text/css">
.flex_row {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
align-content: stretch;
align-items: flex-start;
}
.article {
box-sizing: border-box;
flex: 1 1 50%;
align-self: stretch;
padding: 10px;
}
.content {
box-sizing: border-box;
flex: 1 1 auto;
align-self: stretch;
padding: 0 10px;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
}
.innercontent {
flex: 1 1 auto;
align-self: stretch;
color: green;
}
.buttonBar {
flex: 0 0 auto;
}
.onRight {
text-align: left;
}
</style>
</head>
<body>
<h1 style="color: #006400;">
<br />
GeeksforGeeks
</h1>
<div class="flex_row">
<div class="article onRight flex_row">
<div class="image">
<img src=
"https://media.geeksforgeeks.org/wp-content/uploads/20200712114621/testimg.JPG"
height="150" />
</div>
<div class="content">
<div class="innercontent">
<h1>Hey There..!!</h1>
<p>
<b>This is an Example..</b>
</p>
<p>Here I have used Flexbox model
to set div with left image
and button at bottom.
</p>
<br/>
</div>
<div class="buttonBar">
<button>Click me!</button>
</div>
</div>
</div>
</div>
</body>
</html>
Output:

Similar Reads
How to stick a div at the bottom left of the screen using Bootstrap5 ? In this article, we will see how to stick a div element in the bottom left of the screen using Bootstrap 5 utility classes. Bootstrap is a famous front-end framework used for developing websites. Bootstrap provides a collection of built-in design components, and styles for making the design easier.S
2 min read
How to put images in a box without space using Bootstrap? Bootstrap 4 is a CSS a library for frontend web development developed by Twitter which helps the developer to beautify the way the webpage looks. The bootstrap library has pre-defined CSS classes that are easy to use and it helps the developer to provide an artistic look to the website with minimal
3 min read
How to Adjust Images with Different Sizes to the Same Size using Bootstrap ? Images are an indispensable part of any website. Many websites, such as e-commerce sites, news sites, etc., display numerous images in the same row and column, and the images need to be displayed as per a standard size for a better user experience. We will look at how to adjust images with different
2 min read
How to align button to right side of text box in Bootstrap? Aligning a button to the right of a text box in Bootstrap involves enclosing both within an "input-group" container. By adding the "input-group-append" class to the container, Bootstrap automatically positions the button to the right of the text box.There are some Common approaches :Table of Content
2 min read
How to Left & Right Align Text within a Div in Bootstrap ? Bootstrap is used to customize the appearance and layout of web applications. To left and right align text within a <div> in Bootstrap, we can use utility classes such as text-start and text-end, combined with the grid system for responsive design. Below are the approaches to let and right ali
2 min read
How to add a button to an image using CSS ? In the article, we will explore how to add a button to an image using CSS. Adding a button to an image is often used to create an overlay effect to a button on an image that provides an interactive and engaging layout on a webpage. We can achieve this effect with the combination of various CSS Prope
4 min read
How to place button in top Right corner using bootstrap? To place a button in the top right, there are several ways to do this. The easiest way to do this, Set "pull-right" in button class. Example: html <!DOCTYPE html> <html lang="en"> <head> <title> place button in top right corner </title> <meta charset="
1 min read
How to create Responsive Bottom Navigation Bar using Bootstrap ? A navigation bar is used in every website to make it more user-friendly so that the navigation through the website becomes easy and the user can directly search for the topic of their interest. The word "Navigation" means the science of moving from one place to another. In this article, we create a
5 min read
How to set the button alignment in Bootstrap ? Bootstrap buttons are no different from any other DOM elements of an HTML document. Aligning them is more likely the same as aligning paragraphs, divs and sections. Here are some of the scenarios that one can encounter.Here we are using some common methods:Table of ContentButtons in container classB
4 min read
How to make div that contains images to have fixed size using Bootstrap ? In this article, we will see how we can make a div that will contain images having a fixed size. This can be very helpful when designing a webpage for displaying a certain type of product. We will use bootstrap to implement the solution for the above problem. Bootstrap CDN link: https://stackpath.bo
1 min read