Placing blob background directly under the image - html

What am I trying to achieve is to have a blob background behind the orange. The most important thing is that whenever window is resized that the blob will always stay directly behind the orange and not move to left or right. Could anybody help me achieve that? I would appreciate that very much.
<!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="jumbotron text-center">
<h1>Hello Everyone</h1>
</div>
<div class="container">
<div class="row">
<div class="col-sm-6 col-6">
<h3>Column 1</h3>
<p>I would like to place the blob directly behind the orange</p>
<p>And then block the movement so whenever window is resized all is in the same place</p>
</div>
<div class="col-sm-6 col-6" style="position:relative;left:0;top:0">
<img src="http://riviste.newbusinessmedia.it/wp-content/uploads/sites/27/2013/12/Fotolia_11313277_M.jpg"
style="width:100%;">
<img src="https://d3b1ak9ylguumf.cloudfront.net/stencil/public/static/images/wave-blob.svg?h=b9d69d25&v=2020-08-19.00" style="position:absolute;">
</div>
</div>
</div>
</body>
</html>

You should position your element with left: 0; top: 0; (putting it on relative element has no effect):
.images {
position: relative;
}
.images .bottom-image {
width: 100%;
position: relative;
z-index: 5;
opacity: .9
}
.images .top-image {
position: absolute;
top: 0;
left: 0;
width: 100%;
opacity: .9;
z-index: 4;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<div class="jumbotron text-center">
<h1>Hello Everyone</h1>
</div>
<div class="container">
<div class="row">
<div class="col-sm-6 col-6">
<h3>Column 1</h3>
<p>I would like to place the blob directly behind the orange</p>
<p>And then block the movement so whenever window is resized all is in the same place</p>
</div>
<div class="col-sm-6 col-xs-6 images">
<img class="bottom-image" src="http://riviste.newbusinessmedia.it/wp-content/uploads/sites/27/2013/12/Fotolia_11313277_M.jpg"/>
<img class="top-image" src="https://d3b1ak9ylguumf.cloudfront.net/stencil/public/static/images/wave-blob.svg?h=b9d69d25&v=2020-08-19.00"/>
</div>
</div>
</div>

You can insert the blob image as background-image property of the div.
You can read more about it on https://www.w3schools.com/cssref/pr_background-image.asp
Note: Here orange has white background, so cant see clearly, you can check it with some transparent background image.
<!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="jumbotron text-center">
<h1>Hello Everyone</h1>
</div>
<div class="container">
<div class="row">
<div class="col-sm-6 col-6">
<h3>Column 1</h3>
<p>I would like to place the blob directly behind the orange</p>
<p>And then block the movement so whenever window is resized all is in the same place</p>
</div>
<div class="col-sm-6 col-6" style="position:relative;left:0;top:0; background-image: url('https://d3b1ak9ylguumf.cloudfront.net/stencil/public/static/images/wave-blob.svg?h=b9d69d25&v=2020-08-19.00');">
<img src="https://riviste.newbusinessmedia.it/wp-content/uploads/sites/27/2013/12/Fotolia_11313277_M.jpg"
style="width:100%;">
</div>
</div>
</div>
</body>
</html>

Related

how to make my cards to be in the center but always start on the left side?

I want to make a screen with buttons responsively, these buttons are square, they should be next to each other, but as soon as the line breaks they should start on the left side, but always stay in the center. I'm using bootstrap-5, but I don't know how to do that. I tried with flex-box.
My code:
.box {
height: 65px;
width: 60px;
background: black;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
</head>
<body>
<div class="d-flex flex-wrap gap-4 w-50 border border-primary">
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
</body>
</html>
Nest the flexbox in another div. Then give it the mx-auto class to center itself in the middle of the parent div.
Now give the parent div the class w-50 and change the width of the flexbox to the width you want.
.box {
height: 65px;
width: 60px;
background: black;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container px-5 border border-primary">
<div class="d-flex flex-wrap gap-4 w-75 mx-auto">
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
</div>
</div>
Based on my small knowledge in bootstrap I think you should add p-5 as an example to your container div .
P-(number between 1 & 5) representing the padding so in this way the boxes will have the space you want to stay away from the border.
.box{
height:65px;
width: 60px;
background: black;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
</head>
<body>
<div class="d-flex p-3 flex-wrap gap-4 w-50 border border-primary">
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
<div class="box">
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
</body>
</html>

Display bootstrap card on top right of the screen

How can I move my Bootstrap card to the top-right of the screen?
This is my current html code (a snippet of it):
<div class="card-text" style="max-width: 18rem;">
<div class="card-body">
<h5 class="card-title">{{c.Name}} {{c.Surname}}</h5>
<p class="card-text">{{ c.role }}</p>
</div>
</div>
I have looked through the documentation of bootstrap and tried almost everything. Anyone an idea?
Here you go...
You have to wrap your content with a wrapper and add this to your CSS:
#wrapper {
position: absolute;
top: 0;
right: 0;
}
See the snippet below.
#wrapper {
position: absolute;
top: 0;
right: 0;
}
<!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'>
<title>Document</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.1/dist/css/bootstrap.min.css">
</head>
<body>
<div id='wrapper'>
<div class='card-text' style='max-width: 18rem;'>
<div class='card-body'>
<h5 class='card-title'>{{c.Name}} {{c.Surname}}</h5>
<p class='card-text'>{{ c.role }}</p>
</div>
</div>
</div>
</body>
</html>
You can move it by putting it in a wrapper. If you don't want to add it to a CSS you can just place it within style tags in the HTML head.
<!DOCTYPE html>
<html lang='en'>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
<style>
#wrapper {
position: absolute;
top: 0;
right: 0;
}
</style>
</head>
<body>
<div id='wrapper'>
<div class="card" style="width: 18rem;">
<div class='card-text' style='max-width: 18rem;'>
<img src="..." class="card-img-top" alt="...">
<div class='card-body'>
<h5 class='card-title'>{{c.Name}} {{c.Surname}}</h5>
<p class='card-text'>{{ c.role }}</p>
</div>
</div>
</div>
</div>
</body>
</html>

Bootstrap, can't get image to go to rightside of jumbotron

<div class="jumbotron jumbotron-fluid" id="landing">
<div class="container">
<div class="row">
<div class="col-sm-6"><h1>Hey, I'm A Man <br> Thanks for coming</h1></div>
<div class="col-sm-6"><img class="img-responsive" src="example.png" alt=""></div>
</div>
</div>
</div>
CSS for Jumbotron (Not entirely sure if this is reason it's messing up so leaving it here just incase)
#landing {
background-image: url(jumboimg);
background-size: cover;
height: 800px;
margin-top: -80px;
}
Heres what it's coming out as
https://i.imgur.com/7wXdWeb.png
I'm trying to get it to the right of the text
See below code sample, I have tried to replicate same and it works
and yes there was closing </h1> missing in the code
#landing {
background-image: url(https://www.vklalco.com/wp-content/uploads/2018/03/mumbai_night-800x400.jpg);
background-size: cover;
height: 800px;
/* margin-top: -80px; */
padding: 20px;
color: #fff;
}
img.img-responsive {
max-width: 100%;
}
<!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.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://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="jumbotron jumbotron-fluid" id="landing">
<div class="container">
<div class="row">
<div class="col-sm-6"><h1>Hey, I'm A Man <br> Thanks for coming</h1></div>
<div class="col-sm-6">
<img class="img-responsive" src="https://www.pentasia.com/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBdHJKIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--94a7bbc0f18502cae6a97b304f2712e26588fd1e/pentasia-surrey-redhill2.jpg" alt="">
</div>
</div>
</div>
</div>
<p>This is some text.</p>
<p>This is another text.</p>
</div>
</body>
</html>
width 100% will make your image fit to your column
<img class="img-responsive" src="example.png" alt="" width="100%">

how to change width using bootstrap during responsiveness?

I'm trying to change the width of the div elements during responsiveness.
so when I reduce the screen width to around 600px the div elements should increase their width to 50%.
Now I noticed no breakpoint for w-* class, and was wondering is there any way to do it??
also I'm allowed to only use bootstrap and avoid as much as possible to add my own CSS.
can any one help??
here is the code snippet
<!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.3/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.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<style>
.d-flex>div
{
height:200px;
background-color:black;
margin-left:10px;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="card bg-light">
<div class="card-body d-flex align-items-center flex-wrap">
<div class="flex-grow-1">
</div>
<div class="flex-grow-1 ">
</div>
<div class="flex-grow-1 ">
</div>
<div class="flex-grow-1 ">
</div>
<div class="flex-grow-1 ">
</div>
</div>
</div>
</div>
</body>
</html>
you can do it with pinch of jquery code like below,
if(jQuery(window).width() < 601px){
jQuery('.your-div-class').addClass('w-50');
}
else {
jQuery('.your-div-class').removeClass('w-50');
}
Please make sure you have included jquery in your page as well.
Bootstrap's break points are Small 540px and Medium 720px. So you could try the following. This example defaults to 5 blocks per row, and then 2 blocks per row on a small break point.:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!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.3/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.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<style>
.d-flex {
height: 200px;
background-color: black;
border: 1px solid yellow;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="card bg-light">
<div class="card-body row">
<div class="d-flex col-6 col-sm-2">
</div>
<div class="d-flex col-6 col-sm-2">
</div>
<div class="d-flex col-6 col-sm-2">
</div>
<div class="d-flex col-6 col-sm-2">
</div>
<div class="d-flex col-6 col-sm-2">
</div>
</div>
</div>
</div>
</body>
</html>

Bootstrap 3 merge rows and columns

I can't figure out what is the problem with my code. I'm very new in bootstrap my problem is kinda trivial. One of my field is out of position. I have tried a different route by making only one row and instead of increasing the div sizes I reduced them, but it had the exact same problem. (Run the code in full screen mode).
Please if you can help me out!
.row {
background-color: yellow;
}
.col-sm-3, .col-sm-6 {
border:solid 2px black;
}
div {
height:200px;
}
.two-div {
height:400px;
}
.three-div {
height:600px;
}
<!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.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/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">
<div class="col-sm-3 three-div pull-left">Works</div>
<div class="col-sm-6">Works</div>
<div class="col-sm-3 two-div pull-right">Works</div>
</div>
<div class="row">
<div class="col-sm-3 two-div">Works</div>
<div class="col-sm-3 three-div">Works</div>
</div>
<div class="row">
<div class="col-sm-3 two-div pull-right">Works</div>
</div>
<div class="row">
<div class="col-sm-6">:(</div>
</div>
</div>
</body>
</html>
With some nesting and pull-right on the appropriate columns you can reverse the float:left and make it work (albeit a hack!)...
http://www.codeply.com/go/rgHEL6DW12
<div class="container">
<div class="row">
<div class="col-sm-9">
<div class="row">
<div class="col-sm-4 three-div">works</div>
<div class="col-sm-8">works</div>
<div class="col-sm-4 three-div pull-right">works</div>
<div class="col-sm-4 two-div pull-right">works</div>
<div class="col-sm-8 pull-right">
;-)
</div>
</div>
</div>
<div class="col-sm-3">
<div class="row">
<div class="col-sm-12 two-div">works</div>
<div class="col-sm-12 two-div">works</div>
</div>
</div>
</div>
</div>
Think about it like this...
http://www.codeply.com/go/rgHEL6DW12
Your unhappy smiley box is off because your setting different heights for the containers. I altered your code to explain how you work with BS grid system. See comments.
.row {
background-color: yellow;
}
.col-sm-3,.col-sm-6 {
border:solid 2px black;
}
div { height:200px; }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<!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.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/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">
<div class="col-sm-3 three-div">Works</div> <!-- no need for pulling left. BS does that already -->
<div class="col-sm-6">Works</div>
<div class="col-sm-3 two-div">Works</div> <!-- no need for pulling right -->
</div>
<div class="row">
<div class="col-sm-3 two-div">Works</div>
<div class="col-sm-3 three-div">Works</div>
</div>
<div class="row">
<div class="col-sm-3 col-sm-offset-9">Works</div> <!-- use -offset-X to move your divs horizontally along the grid -->
</div>
<div class="row">
<div class="col-sm-6">:(</div>
</div>
</div>
</body>
</html>