Bootstrap offset is not working - html

I'm just trying to experiment with Bootstrap and I cannot make the offset to work and I don't know why. Here's my code:
<div class="container">
<div class="row justify-content-between align-items-stretch">
<div class="col-4 offset-2"> ABC </div>
<div class="col-4"> DEF </div>
</div>
</div>
For some reason the offset-2 doesn't move the column at all. Do you know why?
Thanks in advance,

Hope this will work according to your requirements:-
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/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/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row justify-content-between align-items-stretch">
<div class="col-4 col-md-offset-2">
ABC
</div>
<div class="col-4">
DEF
</div>
</div>
</div>
</body>
</html>

Related

Adding another box to an existing column using Bootstrap grid

I currently have a Bootstrap grid that looks as follows:
The code is:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU"
crossorigin="anonymous">
<title>Example</title>
</head>
<body>
<div class="container-fluid">
<div class="row justify-content-center">
<div class="align-self-center">
<h1>Box 1</h1>
</div>
</div>
<div class="row">
<div class="col-6">
<div id="left-panel" class="row justify-content-center">
<div class="align-self-center">
Box 2
</div>
</div>
</div>
<div id="right-panel" class="col-6">
<div class="row justify-content-center">
<div class="align-self-center">
Box 3
</div>
</div>
</div>
</div>
</div>
</body>
</html>
I would like to add a Box 4 to the grid, as seen below:
How would I amend my code to do this?
Thanks!
Pls Check below one,we used nested div :
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.1/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU"
crossorigin="anonymous">
<title>Example</title>
</head>
<body>
<div class="container-fluid border border-dark text-center">
<div class="row justify-content-center">
<div class="align-self-center">
<h1>Box 1</h1>
</div>
</div>
<div class="row border border-dark">
<div class="col-6">
<div id="left-panel col-12 border border-dark" class="row justify-content-center">
<div class="align-self-center border border-dark">
Box 2
</div>
</div>
<div id="left-panel-1 col-12 border border-dark" class="row justify-content-center">
<div class="align-self-center border border-dark">
Box 4
</div>
</div>
</div>
<div id="right-panel" class="col-6 border border-dark">
<div class="row justify-content-center">
<div class="align-self-center">
Box 3
</div>
</div>
</div>
</div>
</div>
</body>
</html>

Boostrap chat keeping message box at bottom of screen

Hi I am trying to have a row stay at the bottom of the screen for a message send input box, the problem I am having is that if I set the row:
row d-flex position-absolute bottom-0
the columns are not taking the horizontal space in the row.
here is my Boostrap 5 code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous" />
<link rel="stylesheet" href="styles.css" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" />
<title>Stripe connect</title>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-lg-3 bg-primary sidebar">
<div class="px-3 py-3"></div>
</div>
<div class="col bg-secondary">
<div class="row bg-success d-flex align-items-start flex-column vh-100">
ff
</div>
<div class="row d-flex position-absolute bottom-0">
<div class="col bg-danger">ff</div>
<div class="col">ff</div>
<div class="col">ff</div>
</div>
</div>
</div>
</div>
<!-- Option 1: Bootstrap Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
</body>
</html>
and here is an image:
columns are to the left and not taking up the full width
Thanks for the help
Since you're deliberately placing the utility classes also specify the start-0 and end-0 declarations as well. Cheers
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-lg-3 bg-primary sidebar">
<div class="px-3 py-3"></div>
</div>
<div class="col bg-secondary">
<div class="row bg-success d-flex align-items-start flex-column vh-100">
ff
</div>
<div class="row d-flex position-absolute bottom-0 start-0 end-0">
<div class="col bg-danger">ff</div>
<div class="col">ff</div>
<div class="col">ff</div>
</div>
</div>
</div>
</div>

All bootstrap columns are appearing in the same row?

I know its going to be a silly problem, but I am a newbie and its bugging me for a few hours. I am following a container > row > col structure still all my cols are appearing in a same row. As per bootstrap all there should be only 12 columns in a row, and all remaining columns should appear in the next line.
Here is the HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="row m-3 p-3">
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
<div class="col text-center">akjsdajkshd
</div>
</div>
</div>
</body>
</html>
I can't find whats wrong here, will appreciate some help.
enter image description here
I recreated your use case in a CodePen sandbox using the following:
<div class="container">
<div class="row">
<div class="col-sm">1</div>
<div class="col-sm">2</div>
<div class="col-sm">3</div>
<div class="col-sm">4</div>
<div class="col-sm">5</div>
<div class="col-sm">6</div>
<div class="col-sm">7</div>
<div class="col-sm">8</div>
<div class="col-sm">9</div>
<div class="col-sm">10</div>
<div class="col-sm">11</div>
<div class="col-sm">12</div>
</div>
</div>
From Bootstrap's documentation on its Grid system:
The above example creates equal-width columns on small, medium,
large, and extra large devices using our predefined grid classes.
Those columns are centered in the page with the parent .container.
When using Bootstrap, you don't necessarily need to use container-fluid, unless you want to set the container width: 100% at all breakpoints (different devices width: Small ≥ 576px, Medium ≥ 768px, Large ≥ 992px, and so on...). See Bootstrap documentation regarding its Container here.
If you want to set all div to have text-center, you could do the following to avoid adding unnecessary classes to your divs.
<div class="container text-center">
...
</div>
I hope this helps solve your problem! Let me know if you have follow-up questions 🙂
Why you are using fluid container? bootstrap design to work as responsive accordingly.
Make below snippet full screen you will get to know, in this approach when ever grid increase more than 12 it will automatically added in new line
<!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.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<h1>Hello World!</h1>
<div class="row">
<div class="col-sm-4" style="background-color:lavender;">1</div>
<div class="col-sm-4" style="background-color:lavenderblush;">2</div>
<div class="col-sm-4" style="background-color:lavender;">3</div>
<div class="col-sm-4" style="background-color:lavenderblush;">4</div>
<div class="col-sm-4" style="background-color:lavender;">5</div>
</div>
</div>
</body>
</html>

Bootstrap button on right top

I have bootstrap page like this
<div class='container'>
<div class='row'>
<div class='col-sm-6 col-md-4 col-lg-3'>
<p>column1</p>
</div>
<div class='col-sm-6 col-md-4 col-lg-3'>
<p>column2</p>
</div>
<div class='col-sm-6 col-md-6 col-lg-4'>
<p>column3</p>
</div>
<div class='col-sm-2 col-md-2 col-lg-1'>
<button type="button">Button</button>
</div>
</div>
</div>
looks like this when pc
1 row
--------------------------------
|column1|column2|column3|button|
--------------------------------
but I want to change like this when Ipad
Horizontal display mode (1024px)
2 rows
--------------------------------
|column1| |button|
--------------------------------
|column2|column3|
--------------------------------
Is this possible? I tried to use pull-right, text-right, justify-content-end
but it didn't work.
Here is the pure bootstrap solution for your problem, just play with the existing classes, and I have given then BG color just for demo purpose, you can remove it. Enjoy,
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class='container'>
<div class='row'>
<div class='col-xl-4 col-6' style="background-color: red">
<p>column1</p>
</div>
<div class='col-xl-1 col-6 order-xl-3 text-right text-xl-left' style="background-color: yellow">
<button type="button">Button</button>
</div>
<div class='col-xl-7 order-xl-2' style="background-color: green">
<div class="row">
<div class='col-6'>
<p>column2</p>
</div>
<div class='col-6'>
<p>column3</p>
</div>
</div>
</div>
</div>
</div>
You can change the structure as you want button and column 1 in same line and column 2 , 3 in same row as following.
<div class='container'>
<div class='row'>
<div class='col-sm-6 col-md-4 col-lg-3'>
<p>column1</p>
</div>
<div class='col-sm-2 col-md-2 col-lg-offset-8 col-lg-1'>
<button type="button">Button</button>
</div>
</div>
<div class='row'>
<div class='col-sm-6 col-md-4 col-lg-3'>
<p>column2</p>
</div>
<div class='col-sm-6 col-md-6 col-lg-4'>
<p>column3</p>
</div>
</div>
<!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.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>Your title here</title>
</head>
<div class="row">
<div class="col-sm-12">
**Button**
</div>
</div>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</body>
</html>

Why is Bootstrap 4 text-right not working properly?

I want to make the text in the blue column div align on the right side just like the red div, but text-right does not seem to work. I also want the letters to keep sticking together like they do now: [I]|dashboard
This is my 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://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="test.css">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-3 text-right color1setter">
test
</div>
<div class="col-md-3 text-right color2setter">
<div class="row no-gutters">
<div class="col-md-auto ">
[I]
</div>
<div class="col-md-auto ">
|
</div>
<div class="col-md-auto">
Dashboard
</div>
</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
As your auto columns have no width, they are all bunching on the left of your row - add ml-auto (margin-left: auto) class to the first auto col and it will push everything to the right:
<div class="container">
<div class="row">
<div class="col-md-3 text-right color1setter">
test
</div>
<div class="col-md-3 text-right color2setter">
<div class="row no-gutters">
<div class="col-md-auto ml-auto"> <!-- add ml-auto class here -->
[I]
</div>
<div class="col-md-auto ">
|
</div>
<div class="col-md-auto">
Dashboard
</div>
</div>
</div>
</div>
</div>
Example bootply
Bootstrap auto-margins
Colors to the background of your divs were added so as to show the group staying together, using float right for the group.
<div class="container">
<div class="row">
<div class="col-md-3 text-right color1setter" style="background-color: darkred; color: aliceblue">
test
</div>
<div class="col-md-3 text-right color2setter" style="background-color: red">
<div class="row no-gutters" style="float: right;">
<div class="col-md-auto " style="background-color: violet">
[I]
</div>
<div class="col-md-auto " style="background-color: blueviolet">
|
</div>
<div class="col-md-auto" style="background-color: purple;">
Dashboard
</div>
</div>
</div>
</div>