I would like to have two columns on the main page below the header: one on the left displaying social media (which is working fine) and one on the right displaying a little welcoming blurb. I am using the offset column, but it is still giving a gap. If I increase the offset to 4 to reach of total of 12 for the grid, the blurb moves down as if it is going beyond the 12. I'm not sure what I'm missing here.
This is my first time posting on stackoverflow, so hopefully I am including enough code for the problem. If not, let me know. Thanks!
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/styles.css">
<div class="container-fluid">
<section class="social-media col-md-4">
<h3>To Stay Connected</h3>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<img class="media-object" src="../bootstrap/images/instagram.png" alt="Instagram">
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
neon.honey
</div>
</div>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<img class="media-object" src="../bootstrap/images/twitter.png" alt="Twitter">
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
#deephoney
</div>
</div>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<img class="media-object" src="../bootstrap/images/facebook.png" alt="Facebook">
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
Molly
</div>
</div>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<img class="media-object" src="../bootstrap/images/pinterest.png" alt="Pinterest" />
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
Neon Honey
</div>
</div>
</section>
<section class="hello col-md-4 col-md-offset-3">
<h1>hello!</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab libero,
cupiditate veniam officiis itaque in porro iure fugit iusto reprehenderit
commodi earum cum blanditiis quos error similique quod, facere! Hic.</p>
</section>
Make sure you are using the correct window size class:
Class prefix .col-xs- .col-sm- .col-md- .col-lg-
# of columns 12
Column width Auto ~62px ~81px ~97px
http://getbootstrap.com/css/#grid-options
you can use the offset as well like just to complete the rest of the columns you are not using.
just like the example bellow.
I need to use the .col-xs prefix to satisfy the window size of the snippet.
you can also "force" a div to float right or left in the document.
you will need to read this:
http://www.w3schools.com/css/css_float.asp
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<section class="social-media col-xs-4">
<h3>To Stay Connected</h3>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<img class="media-object" src="../bootstrap/images/instagram.png" alt="Instagram">
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
neon.honey
</div>
</div>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<img class="media-object" src="../bootstrap/images/twitter.png" alt="Twitter">
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
#deephoney
</div>
</div>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<img class="media-object" src="../bootstrap/images/facebook.png" alt="Facebook">
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
Molly
</div>
</div>
<div class="row">
<div class="col-lg-2 col-md-2 col-sm-2">
<img class="media-object" src="../bootstrap/images/pinterest.png" alt="Pinterest" />
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
Neon Honey
</div>
</div>
</section>
<section class="hello col-xs-4 col-xs-offset-4">
<h1>hello!</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ab libero,
cupiditate veniam officiis itaque in porro iure fugit iusto reprehenderit
commodi earum cum blanditiis quos error similique quod, facere! Hic.</p>
</section>
</div>
Related
I am following this BootStrap 5 Crash Course: https://www.youtube.com/watch?v=4sosXZsdy-s. This end-result website is: https://www.frontendbootcampdemo.com
In it, there's a part where Cards are used. The problem I am seeing is that if the text length differs, the cards do not align properly. Here is the HTML for that:
<section class="p-5">
<div class="container">
<div class="row text-center g-4">
<div class="col-md">
<div class="card bg-dark text-light">
<div class="card-body text-center">
<div class="h1 mb-3">
<i class="bi bi-laptop"></i>
</div>
<h3 class="card-title mb-3">Virtual</h3>
<p class="card-text">
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
Iure, quas quidem possimus dolorum esse eligendi?
</p>
Read More
</div>
</div>
</div>
<div class="col-md">
<div class="card bg-secondary text-light">
<div class="card-body text-center">
<div class="h1 mb-3">
<i class="bi bi-person-square"></i>
</div>
<h3 class="card-title mb-3">Hybrid</h3>
<p class="card-text">
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
Iure, quas quidem possimus dolorum esse eligendi?
</p>
Read More
</div>
</div>
</div>
<div class="col-md">
<div class="card bg-dark text-light">
<div class="card-body text-center">
<div class="h1 mb-3">
<i class="bi bi-people"></i>
</div>
<h3 class="card-title mb-3">In Person</h3>
<p class="card-text">
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
Iure, quas quidem possimus dolorum esse eligendi?
</p>
Read More
</div>
</div>
</div>
</div>
</div>
</section>
I have tried adding h-100 to the card-body. The problem is that, while all the cards keep the same height, the buttons are not aligned at the bottom.
How do I keep the cards at the same height and keep the buttons aligned at the bottom?
Thank you!
You can play around with flex CSS. Let me demo to you by using back your code.
add .h-100 to .card
add .d-md-flex and .flex-column to .card-body
add .flex-grow-1 to .card-text
Voila~ My method is just demonstratte one of the method to achieve what you want but still it is depends on what you want the layout to become in different screen sizing at the end.
You can refer this page for full capability of flexbox for Bootstrap 5.
Hope it helps.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<section class="p-5">
<div class="container">
<div class="row text-center g-4">
<div class="col-md">
<div class="card bg-dark text-light h-100">
<div class="card-body text-center d-md-flex flex-column">
<div class="h1 mb-3">
<i class="bi bi-laptop"></i>
</div>
<h3 class="card-title mb-3">Virtual</h3>
<p class="card-text flex-grow-1">
Lorem, ipsum dolor sit amet consectetur.
</p>
Read More
</div>
</div>
</div>
<div class="col-md">
<div class="card bg-secondary text-light h-100">
<div class="card-body text-center d-md-flex flex-column">
<div class="h1 mb-3">
<i class="bi bi-person-square"></i>
</div>
<h3 class="card-title mb-3">Hybrid</h3>
<p class="card-text flex-grow-1">
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
</p>
Read More
</div>
</div>
</div>
<div class="col-md">
<div class="card bg-dark text-light h-100">
<div class="card-body text-center d-md-flex flex-column">
<div class="h1 mb-3">
<i class="bi bi-people"></i>
</div>
<h3 class="card-title mb-3">In Person</h3>
<p class="card-text flex-grow-1">
Lorem, ipsum dolor sit amet consectetur adipisicing elit.
Iure, quas quidem possimus dolorum esse eligendi?
</p>
Read More
</div>
</div>
</div>
</div>
</div>
</section>
I wrote below code. The issue was between image and font of refreshment-1 (classes are refreshment s-info-1 and refreshments-pic-1, a gap that just showed the background color of equipment-section and wasn't padding or margin. I tried setting gutters, padding and margins of all elements to 0 but that didn't help.
This is the code that worked. I changed col-lg-3 col-12 d-lg-block d-flex to col-lg-3 col-12 d-flex flex-column , which caused it to work
<div class="equipment-section">
<h1 class="equipment-h1">Our Stock</h1>
<h2 class="equipment-h2">IS AWESOME!</h2>
<div class="container-fluid collage-padding">
<div class="row gx-0">
<div class="col-lg-3 col-8 rackets-info">
<i class="bi bi-tag"></i>
<h3 class="equipment-h3">Racquets</h3>
<span class="separator"></span>
<h4 class="equipment-h4">Yonex Astrox</h4>
<p class="equipment-p">
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Ratione
exercitationem, ex ipsam aliquam eius consequatur ducimus
repellendus nobis delectus at?
</p>
<h4 class="equipment-h4">FRRM 9.99$</h4>
</div>
<div class="col-lg-3 col-4 rackets-pic"></div>
<div class="col-lg-3 col-12 d-flex flex-column">
<div class="col-lg-12 col-8 refreshments-info-1">
<i class="bi bi-tag"></i>
<h3 class="col-small-h3">Refreshments</h3>
<span class="separator-orange"></span>
<h4 class="col-small-h4">PIZZA</h4>
<h5 class="col-small-h5">FROM 4.99$</h5>
</div>
<div class="col-lg-12 col-4 refreshments-pic-1"></div>
</div>
<div class="col-lg-3 col-12 d-lg-block d-flex">
<div class="col-lg-12 col-8 refreshments-pic-2"></div>
<div class="col-lg-12 col-4 refreshments-info-2">
<i class="bi bi-tag"></i>
<h3 class="col-small-h3">Refreshments</h3>
<span class="separator-orange"></span>
<h4 class="col-small-h4">SHAWARMA</h4>
<h5 class="col-small-h5">FROM 15.99$</h5>
</div>
</div>
</div>
I understand why display:flex with flex-direction as column gives me needed result. I want to know why d-lg-block wouldn't give me same result in large screen view. My implementation was this: I had two col-12s inside a col-3 inside a row inside a container.
I have run into a problem when trying to code my semester project.
I'm trying to center all of this content right in the middle of the bootstrap card but It just can't seem to work:(
If someone can help me I would be really grateful!
Also if I can the card height taller.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="card mt-5 container p-5 card-w ">
<div class="row no-gutters">
<div class="col-md-4">
<img src="https://via.placeholder.com/600" class="card-img" alt="apples">
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title h1 pl-5 mx-2 d-flex">Apple, Empire</h5>
<p class="card-text pl-5 mx-2 lead font-weight-bold d-flex">1.94$/kg</p>
<div class="container d-flex alignmentcard">
<div class="d-flex mx-3">
-
<p class="pt-2 lead">1</p>
+
<button class="buttonshad buttonstyling bg-primary text-light mx-5">Add to cart</button>
</div>
</div>
<div class="container pt-4">
<p>
<a class="mx-5" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
More details
</a>
</p>
<div class="collapse" id="collapseExample">
<div class="card card-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sapiente quos ullam, earum commodi autem fuga, aliquam maiores dolorem libero inventore, molestiae omnis nam ipsam error consequatur ut nisi eveniet dolorum!
</div>
</div>
</div>
</div>
</div>
</div>
Try wrapping every piece of your div from the beggining to the end with a <center></center> tag. After that, you would have something like this:
<center>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="card mt-5 container p-5 card-w ">
<div class="row no-gutters">
<div class="col-md-4">
<img src="https://via.placeholder.com/600" class="card-img" alt="apples">
</div>
<div class="col-md-8">
<div class="card-body">
<h5 class="card-title h1 pl-5 mx-2 d-flex">Apple, Empire</h5>
<p class="card-text pl-5 mx-2 lead font-weight-bold d-flex">1.94$/kg</p>
<div class="container d-flex alignmentcard">
<div class="d-flex mx-3">
-
<p class="pt-2 lead">1</p>
+
<button class="buttonshad buttonstyling bg-primary text-light mx-5">Add to cart</button>
</div>
</div>
<div class="container pt-4">
<p>
<a class="mx-5" data-bs-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
More details
</a>
</p>
<div class="collapse" id="collapseExample">
<div class="card card-body">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sapiente quos ullam, earum commodi autem fuga, aliquam maiores dolorem libero inventore, molestiae omnis nam ipsam error consequatur ut nisi eveniet dolorum!
</div>
</div>
</div>
</div>
</div>
</div>
</center>
This question already has answers here:
How to apply a CSS filter to a background image
(22 answers)
Closed 3 years ago.
I'm trying to make the background image blurry. But keep the content above it visible. I think there's a issue because of making the parent element blurry. How can fix this? Tried couple of steps but it didn't really work.
SO Snippet
#clan-profile {
background-image: url(http://placekitten.com/500/200);
height: 300px;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
-webkit-filter: blur(5px);
/* Safari 6.0 - 9.0 */
filter: blur(5px);
}
<section id="clan-profile">
<div class="container">
<div class="row pt-4 pb-4">
<div class="col-12 col-md-6">
<div class="row pb-1">
<div class="col-12">
<h2>Lorem Ipsum</h2>
<h5>Lorem Ipsum</h5>
</div>
</div>
<div class="row pt-1 pb-1">
<div class="col-12">
<img src="https://via.placeholder.com/50x50" alt="" class="img-fluid rounded-circle">
<img src="https://via.placeholder.com/50x50" alt="" class="img-fluid rounded-circle">
<img src="https://via.placeholder.com/50x50" alt="" class="img-fluid rounded-circle">
</div>
</div>
<div class="row pt-1 pb-1">
<div class="col-12">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugit, nulla, sed. Sunt, quo reprehenderit cum ut nihil dolor saepe. Culpa at velit, possimus iste eum ipsum similique sapiente neque aliquam.
</div>
</div>
</div>
<div class="col-12 col-md-6 pt-3">
<img src="https://via.placeholder.com/500x200" alt="clan-img" class="img-fluid">
</div>
</div>
</div>
</section>
If possible I would suggest to split up the parent element clan-profile and the background image.
You could do something like:
<section id="clan-profile">
<div class="clan-image"></div>
<div class="container">
<div class="row pt-4 pb-4">
<div class="col-12 col-md-6">
<div class="row pb-1">
<div class="col-12">
<h2>Lorem Ipsum</h2>
<h5>Lorem Ipsum</h5>
</div>
</div>
...
Then you could do the following css:
.clan-image {
background-image: url("...");
/* Add the blur effect */
filter: blur(5px);
-webkit-filter: blur(5px);
}
Then you have a decision to make. You can either make the image absolutely positioned, or you can make the content absolutely positioned. Another solution is to use css-grid, and position the elements on top of each other, because grid allows for this.
Edit:
Added Example: https://jsfiddle.net/dw2Lq0zj/
I want clear space form my HTML code.
<div class="row">
<div class="col-xs-1">
<img src="~/Content/assets/images/male.jpg" style="height:35px;" class="img-responsive" alt="Cinque Terre">
</div>
<div class="col-md-10">
<p class="pull-left text-primary text-capitalize text-weight-bold">Deneme</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
</div>
</div>
I don't think it is possible because the space between the user image and the username is default by the bootstrap grid system.
By the way, you have a col-xs-1 and a col-md-10 in one row, I don't know for sure if that is 100% right...