hi I wants to show these columns in horizontal manner but these are showing in vertical manner ow can I change it;
blade file:
<div class="col-lg-3 mb-4">
<!-- Input & Button Groups -->
#foreach($category->products as $pro_data)
<div class="card card-small mb-4">
<div class="card-header border-bottom">
<h6 class="m-0">{{ $pro_data->product_name }}</h6>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item px-3">
<div class="input-group mb-3">
<div class="input-group input-group-seamless">
<img src="{{ URL::to('/') }}/images/backend_images/category_images/{{ $pro_data->product_image }}" class="img-thumbnail" style="width: 400px; height: 300px;" />
</div>
</div>
</li>
</ul>
</div>
#endforeach
<!-- / Input & Button Groups -->
</div>
If I understand you correctly you are trying to show the products of the categories next to each other horizontally but you are seeing them vertically at the moment.
I think a proper way would wrap the foreach with your
<div class="col-lg-3 mb-4"></div> which gives us
<div class="row">
#foreach($category->products as $pro_data)
<div class="col-lg-3 mb-4">
<div class="card card-small mb-4">
<div class="card-header border-bottom">
<h6 class="m-0">{{ $pro_data->product_name }}</h6>
</div>
<div class="input-group mb-3">
<div class="input-group input-group-seamless">
<img src="{{ URL::to('/') }}/images/backend_images/category_images/{{ $pro_data->product_image }}" class="img-thumbnail" style="width: 400px; height: 300px;" />
</div>
</div>
</div>
</div>
#endforeach
</div>
Hope it helps!
#foreach($category->products as $pro_data)
<div class="col-lg-3 mb-4">
<!-- Input & Button Groups -->
<div class="card card-small mb-4">
<div class="card-header border-bottom">
<h6 class="m-0">{{ $pro_data->product_name }}</h6>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item px-3">
<div class="input-group mb-3">
<div class="input-group input-group-seamless">
<img src="{{ URL::to('/') }}/images/backend_images/category_images/{{ $pro_data->product_image }}" class="img-thumbnail" style="width: 400px; height: 300px;" />
</div>
</div>
</li>
</ul>
</div>
</div>
#endforeach
Hope this will work for.
I would float the divs to the left with some padding and use clearfix if needed.
All cards appeared in the horizontal manner because you might did't wrap them all without .row class
Because a set of css properties are applied to the .row class
Try the following approach:
<div class="row">
<div class="col-lg-3 mb-4">
</div>
</div>
Your code should be something like this. Added a row wrapper and col inside the loop. I assume <div class="col-lg-3 mb-4"> is your container for all cards.
<div class="col-lg-3 mb-4">
<!-- Input & Button Groups -->
<div class="row">
#foreach($category->products as $pro_data)
<div class="col">
<div class="card card-small mb-4">
<div class="card-header border-bottom">
<h6 class="m-0">{{ $pro_data->product_name }}</h6>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item px-3">
<div class="input-group mb-3">
<div class="input-group input-group-seamless">
<img src="{{ URL::to('/') }}/images/backend_images/category_images/{{ $pro_data->product_image }}" class="img-thumbnail" style="width: 400px; height: 300px;" />
</div>
</div>
</li>
</ul>
</div>
</div>
#endforeach
<!-- / Input & Button Groups -->
</div><!-- end of row -->
</div>
in bootstrap 4 you can use columns in horizontal manner. You did't wrap them all without use .row class this is most important class.
this is the right way if you use bootstrap 4
<div class="row">
<div class="col-md-3 mb-4"></div>
<div class="col-md-3 mb-4"></div>
<div class="col-md-3 mb-4"></div>
<div class="col-md-3 mb-4"></div>
</div>
#foreach($category->products as $pro_data)
<div class="row">
<div class="col-lg-3 mb-4">
<div class="card card-small mb-4">
<div class="card-header border-bottom">
<h6 class="m-0">{{ $pro_data->product_name }}</h6>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item px-3">
<div class="input-group mb-3">
<div class="input-group input-group-seamless">
<img src="{{ URL::to('/') }}/images/backend_images/category_images/{{ $pro_data->product_image }}" class="img-thumbnail" style="width: 400px; height: 300px;" />
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
#endforeach
Related
Hi I am using Bootstrap 4, I am working on a project here http://eatout.sanaalitech.com/products.php I am facing a very strange problem.I am using bootstrap grid and my columns overlaps on the first page load only on mobile view,on desktop it works fine, when I refresh the page it works fine on the mobile as well.
I have tried the following but still not working
1) .col-lg-3{ display:block; position:relative;}
2) I have tried enclosing every 4 products in a row instead of taking all of them in a single row like this
content here
content here
content here
content here
content here
content here
content here
content here
content here
content here
content here
content here
3) I have also completely deleted this and made it again with cards but they also overlap on the first load only on mobile view.
Problem appears on the first load only.
I have added image on first page load .
<div class="container" style="margin-top:5em;">
<div class="row ">
<div class="col-lg-12" >
<ul class="filter-tabs text-center">
<li data-filter=".maincourse"><a href="#!" >Main Courses</a></li>
<li data-filter=".desserts">Desserts</li>
<li class="active" data-filter="*">View All</li>
<li data-filter=".starters">Starters</li>
<li data-filter=".extras">Extras</li>
</ul>
<div class="projects">
<div class="row">
<div class="col-lg-3 item maincourse mb-3" >
<div class="product ">
<img src="Images/banner-image4.jpg" class="img-fluid">
<div class="text-center mb-3 mt-3">
<h4>Meal Platter</h4>
<h7>£8.99</h7>
</div>
</div>
</div>
<div class="col-lg-3 item desserts mb-3" >
<div class="product ">
<img src="Images/dessert.jpg" class="img-fluid">
<div class="text-center mb-3 mt-3">
<h4>Meal Platter</h4>
<h7>£8.99</h7>
</div>
</div>
</div>
<div class="col-lg-3 item maincourse mb-3">
<div class="product ">
<img src="Images/main-meal-5.jpg" class="img-fluid img-filter">
<div class="text-center mb-3 mt-3">
<h4>Meal Platter</h4>
<h7>£8.99</h7>
</div>
</div>
</div>
<div class="col-lg-3 item starters mb-3">
<div class="product ">
<img src="Images/banner-image3.jpg" class="img-fluid">
<div class="text-center mb-3 mt-3">
<h4>Meal Platter</h4>
<h7>£8.99</h7>
</div>
</div>
</div>
<div class="col-lg-3 item maincourse mb-3">
<div class="product ">
<img src="Images/main-meal-2.jpg" class="img-fluid">
<div class="text-center mb-3 mt-3">
<h4>Roll Platter</h4>
<h7>£8.99</h7>
</div>
</div>
</div>
<div class="col-lg-3 item starters mb-3">
<div class="product ">
<img src="Images/main-meal-4.jpg" class="img-fluid">
<div class="text-center mb-3 mt-3">
<h4>Vege Starter</h4>
<h7>£7.99</h7>
</div>
</div>
</div>
<div class="col-lg-3 item desserts mb-3">
<div class="product ">
<img src="Images/dessert-2.jpg" class="img-fluid img-filter">
<div class="text-center mb-3 mt-3">
<h4>Rasberry cake</h4>
<h7>£4.99</h7>
</div>
</div>
</div>
<div class="col-lg-3 item maincourse mb-3">
<div class="product ">
<img src="Images/main-meal-3.jpg" class="img-fluid">
<div class="text-center mb-3 mt-3">
<h4>Burger Meal</h4>
<h7>£8.99</h7>
</div>
</div>
</div>
<div class="col-lg-3 item extras mb-3">
<div class="product">
<img src="Images/extras-1.jpg" class="img-fluid">
<div class="text-center mb-3 mt-3">
<h4>Macaroni Sallad</h4>
<h7>£7.99</h7>
</div>
</div>
</div>
<div class="col-lg-3 item maincourse mb-3">
<div class="product ">
<img src="Images/main-meal-6.jpg" class="img-fluid">
<div class="text-center mb-3 mt-3">
<h4>Fish & Beans</h4>
<h7>£12.99</h7>
</div>
</div>
</div>
<div class="col-lg-3 item extras mb-3">
<div class="product ">
<img src="Images/extras-2.jpg" class="img-fluid img-filter">
<div class="text-center mb-3 mt-3">
<h4>Avacado Sallad</h4>
<h7>£9.99</h7>
</div>
</div>
</div>
<div class="col-lg-3 item desserts mb-3">
<div class="product">
<img src="Images/dessert-3.jpg" class="img-fluid">
<div class="text-center mb-3 mt-3">
<h4>Chocolate Cake</h4>
<h7>£7.99</h7>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
When your grid overflows, run this in the console.
(Code from javascript.js at line 217)
var $projects = $(".projects");
$projects.isotope({
itemSelector: ".item",
layoutMode:'fitRows'
});
I think that this function runs before everything loads.
I don't know what is going on because sometimes this fixes the issue once called but most of the time it does not. But one is for sure. A function defines the absolute position, so the issue lays somewhere within the javascript source.
I am used two images button and place them in a a tag in the same bootstrap column. However this is how they look like:
This is my code:
<body>
<div class="backgroundImage">
<div class="text-right p-3">
<b>{{ __('Be A Dealer') }}</b>
</div>
<div class="container mt-4 mb-4">
<div class="row">
<div class="col-4 col-md-4 mx-auto my-auto">
<img class="mw-100" src="{{ asset('storage/logo/Bujishu_logo.png') }}" alt="Bujishu">
</div>
</div>
</div>
<div class="container">
<div class="row mb-4">
<div class="col-12 col-md-8 offset-md-2 text-center">
<h2 class="bujishu-motto">
A home is made of
<i>
<p class="bujishu-recursive">hopes</p>
</i>
and
<i>
<p class="bujishu-recursive">dreams</p>
</i>
</h2>
<h2 class="bujishu-motto">
Let us
<i>
<p class="bujishu-recursive">inspire</p>
</i>
you to build the perfect home!
</h2>
</div>
</div>
<div class="row mt-4">
<div class="col-6 col-md-4 offset-md-3 ">
<img class="landing_button" src="{{ asset('storage/buttons/Login-Icon.png') }}" alt="Login">
{{-- </div>
<div class="col-6 col-md-4 "> --}}
<img class="landing_button" src="{{ asset('storage/buttons/Sign-Up.png') }}" alt="Sign Up">
</div>
</div>
</div>
</div>
</div>
</body>
How do I align so the next two buttons are next to each other with some spacing between them as well?
Use d-flex and class in your col.
<div class="col-6 col-md-4 offset-md-3 d-flex">
You can also add pl-3 class to SIGN UP button for the space between the buttons.
If you are using Bootstrap 4 it will work if you use two columns, each of size 6 or you can change the size of columns accordingly.
<body>
<div class="backgroundImage">
<div class="text-right p-3">
<b>{{ __('Be A Dealer') }}</b>
</div>
<div class="container mt-4 mb-4">
<div class="row">
<div class="col-4 col-md-4 mx-auto my-auto">
<img class="mw-100" src="{{ asset('storage/logo/Bujishu_logo.png') }}" alt="Bujishu">
</div>
</div>
</div>
<div class="container">
<div class="row mb-4">
<div class="col-12 col-md-8 offset-md-2 text-center">
<h2 class="bujishu-motto">
A home is made of
<i>
<p class="bujishu-recursive">hopes</p>
</i>
and
<i>
<p class="bujishu-recursive">dreams</p>
</i>
</h2>
<h2 class="bujishu-motto">
Let us
<i>
<p class="bujishu-recursive">inspire</p>
</i>
you to build the perfect home!
</h2>
</div>
</div>
<div class="row mt-4">
<div class="col-6 col-md-6">
<img class="landing_button" src="{{ asset('storage/buttons/Login-Icon.png') }}" alt="Login">
</div>
<div class="col-6 col-md-6">
<img class="landing_button" src="{{ asset('storage/buttons/Login-Icon.png') }}" alt="Sign Up">
</div>
</div>
</div>
</div>
</body>
the entire row columns are about 12 columns so it should be col-md-6 or add d-flex to the row itself.
<div class="row mt-4">
<div class="col-6 col-md-6 ">
<img class="landing_button" src="{{ asset('storage/buttons/Login-Icon.png') }}" alt="Login">
</div>
<div class="col-6 col-md-6 ">
<img class="landing_button" src="{{ asset('storage/buttons/Sign-Up.png') }}" alt="Sign Up">
</div>
</div>
I'm trying to create a grid using the Bootstrap 4 card component. For this, I have read the documentation and used the card-deck option. I want that every row has two columns with a similar behaviour to col-12 col-md-6, with the particularity that the second column will also be splited into two rows, each one having an horizontal card. I have this piece of code:
<div class="container">
<div class="row">
<div class="card-deck">
<div class="card">
<img
class="card-img-top"
src$="{{getArticleImage2(article1)}}"
/>
<div class="card-body py-2">
<div class="d-flex justify-content-start align-items-center mb-2">
<img class="icon-sm mr-2 img-fluid" src={{getFavIcon(article1)}}>
<a class="card-link medium-text" target="_blank" href$="https://{{getSources(article1)}}">
{{getSources(article1)}}
</a>
</div>
<p class="card-text article-headline medium-text">
{{article1.schema:headline}}
</p>
</div>
</div>
<div class="card">
<div class="row no-gutters">
<div class="col-md-5">
<img
class="card-img"
src$="{{getArticleImage2(article2)}}"
/>
</div>
<div class="col-md-7">
<div class="card-body p-2">
<div class="d-flex justify-content-start align-items-center mb-2">
<img class="icon-sm mr-2 img-fluid" src={{getFavIcon(article2)}}>
<a class="card-link medium-text" target="_blank" href$="https://{{getSources(article2)}}">
{{getSources(article2)}}
</a>
</div>
<p class="card-text article-headline medium-text">
{{article2.schema:headline}}
</p>
</div>
</div>
</div>
</div>
<div class="card">
<div class="row no-gutters">
<div class="col-md-5">
<img
class="card-img"
src$="{{getArticleImage2(article2)}}"
/>
</div>
<div class="col-md-7">
<div class="card-body p-2">
<div class="d-flex justify-content-start align-items-center mb-2">
<img class="icon-sm mr-2 img-fluid" src={{getFavIcon(article3)}}>
<a class="card-link medium-text" target="_blank" href$="https://{{getSources(article3)}}">
{{getSources(article3)}}
</a>
</div>
<p class="card-text article-headline medium-text">
{{article3.schema:headline}}
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
The problem is that with this disposition I have three cols instead of two. The last two cards are displayed horizontally, but they are not stacked one below the other. Here is a code snippet. How could I achieve this?
if you added a div with class card-columns like that:
<div class="card-deck">
<div class="card-columns">
<div class="card">
<img
class="card-img-top"
src=""
/>
<div class="card-body py-2">
//.................
it will give you two cloumns one with a card displayed vertically and the other contains two horizontal cards.
Also read the last section of the documentation maybe it will be helpful for you to specify how many cards included in one column
https://getbootstrap.com/docs/4.3/components/card/
I am having some problems with image position, I have a few columns with title at the top (flex box) the columns height is flex so that that they dynamically adapt the height so they are uniform.
However under the title is a image, I would like the image to always be at the bottom.
My code
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 d-flex">
<div class="card-body flex-fill">
<h4 class="article-preview__headline">title</h4>
<div class="image align-items-end">
<img class="mt-auto" style="width: 100%; height: auto" src="https://picsum.photos/600/400?image=990" alt="Image" />
</div>
<a class="link" href="#">Link goes here</a>
<hr/>
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 d-flex">
<div class="card-body flex-fill">
<h4 class="article-preview__headline">title long title long title long title long title long</h4>
<div class="image align-items-end">
<img class="mt-auto" style="width: 100%; height: auto" src="https://picsum.photos/600/400?image=991" alt="Image" />
</div>
<a class="link" href="#">Link goes here</a>
<hr/>
</div>
</div>
</div>
</div>
You will need to re-order the elements, either by amending the HTML or using the order property.
If each card-body is made a flex-column we can use the order property to make the image div appear last visually in each column and then margin-top:auto to push it to the bottom of the column.
.card-body {
flex: 1;
}
.card-body .image {
order: 2;
margin-top: auto;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 d-flex flex-column">
<div class="card-body flex-fill d-flex flex-column">
<h4 class="article-preview__headline">title</h4>
<div class="image align-items-end">
<img class="mt-auto" style="width: 100%; height: auto" src="http://www.fillmurray.com/300/200" alt="Image" />
</div>
<a class="link" href="#">Link goes here</a>
<hr/>
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 d-flex flex-column">
<div class="card-body flex-fill d-flex flex-column">
<h4 class="article-preview__headline">title long title long title long title long title long</h4>
<div class="image align-items-end">
<img class="mt-auto" style="width: 100%; height: auto" src="http://www.fillmurray.com/300/200" alt="Image" />
</div>
<a class="link" href="#">Link goes here</a>
<hr/>
</div>
</div>
</div>
</div>
Based on Paulie_D's answer
You can accomplish this without extra CSS and with just some additional css classes:
order-1, order-2, order-3 and mt-auto
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 d-flex flex-column">
<div class="card-body flex-fill d-flex flex-column">
<h4 class="order-1 article-preview__headline">title</h4>
<div class="order-3 mt-auto image align-items-end">
<img class="mt-auto" style="width: 100%; height: auto" src="http://www.fillmurray.com/300/200" alt="Image" />
</div>
<a class="order-2 link" href="#">Link goes here</a>
<hr/>
</div>
</div>
<div class="col-lg-3 col-md-4 col-sm-6 col-xs-12 d-flex flex-column">
<div class="card-body flex-fill d-flex flex-column">
<h4 class="order-1 article-preview__headline">title long title long title long title long title long</h4>
<div class="order-3 mt-auto image align-items-end">
<img class="mt-auto" style="width: 100%; height: auto" src="http://www.fillmurray.com/300/200" alt="Image" />
</div>
<a class="order-2 link" href="#">Link goes here</a>
<hr/>
</div>
</div>
</div>
</div>
I have 4 cards that i need to add some spacing between all of them because it looks like they are one into another. I've tried with adding margin-left but it doesn't really work also I've tried to add the class ml-2 but if i do that it will place one card into another row which i also don't want that:(
Code:
<div class="container">
<h2>Test:</h2>
<div class="row">
<div class="col-sm-3">
<div class="card ml-2" style="width: 20rem;">
<img class="card-img-top" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS0lnPcJXGCIDU-L8lq6wdfh9vFzaLupc405LLlxlcKqx4zYnnQ" alt="Card image cap">
<div class="card-body text-center">
<p class="card-text text-center" style="color:black">Dacia Logan</p>
<ul class="list-group list-group-flush">
<li class="list-group-item">
<div class="row">
<div class="col-md-6">
<i class="material-icons"></i><span>15800</span>
</div>
<div class="col-md-6">
<i class="material-icons"></i><span>Bucuresti</span>
</div>
</div>
</li>
</ul>
<button href="#" class="btn btn-danger">Save</button>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card ml-2" style="width: 20rem;">
<img class="card-img-top" src="https://images.pexels.com/photos/170811/pexels-photo-170811.jpeg?auto=compress&cs=tinysrgb&h=350" alt="Card image cap">
<div class="card-body text-center">
<p class="card-text text-center" style="color:black">Dacia Logan</p>
<ul class="list-group list-group-flush">
<li class="list-group-item">
<div class="row">
<div class="col-sm-6">
<i class="material-icons"></i><span>5800</span>
</div>
<div class="col-sm-6">
<i class="material-icons"></i><span>Bucuresti</span>
</div>
</div>
</li>
</ul>
<button href="#" class="btn btn-danger">Save</button>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card ml-2" style="width: 20rem;">
<img class="card-img-top" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS0lnPcJXGCIDU-L8lq6wdfh9vFzaLupc405LLlxlcKqx4zYnnQ" alt="Card image cap">
<div class="card-body text-center">
<p class="card-text text-center" style="color:black">Dacia Logan</p>
<ul class="list-group list-group-flush">
<li class="list-group-item">
<div class="row">
<div class="col-sm-6">
<i class="material-icons"></i><span>5800</span>
</div>
<div class="col-sm-6">
<i class="material-icons"></i><span>Bucuresti</span>
</div>
</div>
</li>
</ul>
<button href="#" class="btn btn-danger">Save</button>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card" style="width: 20rem;">
<img class="card-img-top" src="https://www.carmag.co.za/wp-content/uploads/2016/11/Golf10.jpg" alt="Card image cap">
<div class="card-body text-center">
<p class="card-text text-center" style="color:black">Dacia Logan</p>
<ul class="list-group list-group-flush">
<li class="list-group-item">
<div class="row">
<div class="col-sm-6">
<i class="material-icons"></i><span>5800</span>
</div>
<div class="col-sm-6">
<i class="material-icons"></i><span>Bucuresti</span>
</div>
</div>
</li>
</ul>
<button href="#" class="btn btn-danger">Save</button>
</div>
</div>
</div>
</div>
Thanks!
Try to put padding on the card class:
padding: 10px;
You could use one of the Bootstrap spacing utilities.
https://getbootstrap.com/docs/4.1/utilities/spacing/
For example, place this div between two cards:
<div class="mt-3" />