Displaying items horizontally instead of columns - html

I need to make an index view for my posts, and I choose a photo gallery for that.In my controller I have paginate set at 10.Unfortunately, my column is divided by one, horizontally : https://imgur.com/a/8sUm5eb .
I want to make this to be divided by 2 columns, 5 items/column.Can you give me a little help with that?Thank you.
My view
<!-- Promo Block -->
<div class="container g-pt-100 g-pb-70">
<!-- News Section -->
<div class="u-heading-v3-1 g-mb-30">
<h2 class="h5 u-heading-v3__title g-color-gray-dark-v1 text-uppercase g-brd-primary">Latest News</h2>
</div>
#foreach($posts as $post)
<div class="masonry-grid-item col-sm-6 g-mb-30">
<!-- Blog Background Overlay Blocks -->
<article class="u-block-hover">
<div class="g-bg-cover g-bg-white-gradient-opacity-v1--after">
<img class="d-flex align-items-end u-block-hover__main--mover-down" src="/storage/{{ $post->image }}" alt="Image Description">
</div>
<div class="u-block-hover__additional--partially-slide-up text-center g-z-index-1 mt-auto">
<div class="u-block-hover__visible g-pa-25">
#foreach($post->tags as $tag)
<span class="g-color-white-opacity-0_7 g-font-size-10 text-uppercase">{{ $tag->name }}</span>
<span class="g-color-white-opacity-0_7 g-pos-rel g-top-2 mx-2">·</span>
#endforeach
<h2 class="h4 g-color-white g-font-weight-600 mb-3">
<a class="u-link-v5 g-color-white g-color-primary--hover g-cursor-pointer" href="/post/{{ $post->id }}">{{ $post->caption }}</a>
</h2>
<h4 class="d-inline-block g-color-white-opacity-0_7 g-font-size-11 mb-0">
By,
<a class="g-color-white-opacity-0_7 text-uppercase" href="/post/{{ $post->id }}">{{ $post->user->username }}</a>
</h4>
<span class="g-color-white-opacity-0_7 g-pos-rel g-top-2 mx-2">·</span>
<span class="g-color-white-opacity-0_7 g-font-size-10 text-uppercase">{{ $post->created_at->diffForHumans() }}</span>
<span class="g-color-white-opacity-0_7 g-pos-rel g-top-2 mx-2">·</span>
<span class="g-color-white-opacity-0_7 g-font-size-10 text-uppercase">{{ $post->comments()->count() }} comments</span>
</div>
<a class="d-inline-block g-brd-bottom g-brd-white g-color-white g-font-weight-600 g-font-size-12 text-uppercase g-text-underline--none--hover g-mb-30" href="/post/{{ $post->id }}">Read more</a>
</div>
</article>
<!-- End Blog Background Overlay Blocks -->
</div>
#endforeach
</div>
</div>
<!-- End News Section -->

Make your first foreach like this
<div class="row">
Your foreach
</div>

Related

How to make each product have functioning plus minus button on my product page and add its price to the total amount?

enter image description hereI'm working on Ecommerce Website that sells Coffee and my problem is that the only working plus and minus button is the first coffee. The plus and minus buttons on the others are not functioning. Is it about the for statement where I'm wrong? or the structure of the html isn't right.
I've copied some of the code on cart.html file to make the product page had the option of adding products to the cart and also has a proceed button to the checkout page. The before structure of the site was you click on the image of a product and directed to the addtocart page then to the checkout page.`{% extends 'app/base.html' %}
{% load static %}
{% block title %}Category{% endblock title %}
{% block main-content %}
<div class="container my-5">
<div class="row">
<div class="col-sm-8">
<div class="card">
<div class="card-body">
{% for prod in product %}
<div class="row">
<div class="col-sm-3 text-center align-self-center"><img src="{{prod.product_image.url}}" alt="" srcset="" class="img-fluid img-thumbnail shadow-sm" height="150" width="150"></div>
<div class="col-sm-9">
<div>
<h5>{{prod.title}}</h5>
<p class="mb-2 text-muted small">{{prod.description}}</p>
<div class="my-3">
<label for="quantity">Quantity:</label>
<a class="minus-cart btn" pid={{product.id}}><i class="fas fa-minus-square fa-lg"></i></a>
<span id="quantity">{{quantity}}</span>
<a class="plus-cart btn" pid={{product.id}}><i class="fas fa-plus-square fa-lg"></i></a>
</div>
<div class="d-flex justify-content-between">
<a href="#" class="remove-cart btn btn-sm btn-secondary mr-3" pid={{prod.id}}>Remove item </a>
<p class="mb-0"><span><strong>₱ {{prod.discounted_price}}</strong></span></p>
</div>
</div>
</div>
</div>
<hr class="text-muted">
{% endfor %}
</div>
</div>
</div>
<div class="col-sm-4">
<div class="card">
<div class="card-body">
<h3>The Total Amount </h3>
<ul class="list-group">
<li class="list-group-item d-flex justify-content-between align-items-center border-0 px-0 pb-0" >Amount<span id="amount">₱ {{amount}}</span></li>
<li class="list-group-item d-flex justify-content-between align-items-center px-0">Shipping<span>₱ 144</span></li>
<li class="list-group-item d-flex justify-content-between align-items-center border-0 px-0 mb-3">
<div>
<strong>Total</strong>
</div>
<span id="totalamount"><strong>₱ {{totalamount}}</strong></span>
</li>
</ul>
<div class="d-grid">Place Order</div>
</div>
</div>
</div>
</div>
</div>
{% endblock main-content%}
`

how to display <div> next to each other within a for loop?(laravel)

I'm working on a alumni portal where I need to display the committee member details. I need to print like 4 members in a line and next 4 in the next line. Any solution would be helpful.
<h2>Member Details</h2>
<div class="jumbotron container">
<div class="pull-right">
<a class="btn btn-primary" data-toggle="modal" id="mediumButton" data-target="#mediumModal" data-attr="{{ route('add_details')}}" title="Add Institute Details"> <i class="fas fa-plus-circle"></i>
</a>
</div>
<div class="container main" id="wrapper">
#foreach ($members as $member)
<div class="img-box">
<pre>
<img src="/uploads/image/{{ $member->image }}" width="100" height="100"/>
{{ $member->id }}<br/>
<a> {{ $member->name }}</a>
<!-- #if(($member->id) >=5 )
<span style="white-space: pre-line">
</span>
#endif
</pre> -->
</div>
#endforeach
</div>
</div>
if you use Bootstrap try this
<div class="row">
#foreach ($members as $member)
<div class="col-md-3">
<div class="img-box">
<pre>
<img src="/uploads/image/{{ $member->image }}" width="100" height="100"/>
{{ $member->id }}<br/>
<a> {{ $member->name }}</a>
</pre>
</div>
</div>
#endforeach
</div>
Add "display:grid;" to the container "div" tag You need to define the property.

elements in a foreach loop getting different css/bootstrap styles in laravel

am getting this weird bug whereby css styles are only applying to the first 2 items in my foreach loop.here is my code.
//html code
<div class="row">
#if ($housescategory->isEmpty())
<div class="col-lg-4">
No houses Found At the Moment
</div>
#else
#foreach ($housescategory as $rentalhse)
<div class="col-lg-4">
<section class="card hsecard">
<figure>
<div class="img-overlay hot-home">
#if($rentalhse->vacancy_status==1)
<span class="badge badge-info p-2 rounded-0 statusbadge">Vacants Available</span>
#elseif($rentalhse->vacancy_status==2)
<span class="badge badge-success p-2 rounded-0 statusbadge">Fully Booked</span>
#endif
<img src="{{ asset ('imagesforthewebsite/rentalhouses/rentalimages/medium/'.$rentalhse->rental_image) }}" alt="{{ $rentalhse->rental_name }}">
</div>
{{ $rentalhse->id }}<figcaption>{{ $rentalhse->rental_name }}
</figcaption>
<div class="pricelocation" style="display: flex;
justify-content: space-between;">
<section class="location">
<a class="disabled font-italic h6"><i class="fa fa-map-marker"></i>{{ $rentalhse->houselocation->location_title }}</a>
</section>
<section class="pricelink">
<span class="btn btn-dark">sh.{{ $rentalhse->monthly_rent }}</span>
</section>
</div>
</figure>
<div class="card-content">
<p>{!! Str::limit($rentalhse->rental_details, 80)!!}</p>
<section class="icons-home">
<div class="name-icon">
#if ($rentalhse->cctv_cameras == 'yes')
<span>CCtv Security Cameras</span>
<div class="icon">
<i class="fa fa-camera-retro"></i>
<span>Available</span>
</div>
#endif
</div>
<div class="name-icon">
#if ($rentalhse->parking == 'yes')
<span>Parking</span>
<div class="icon">
<i class='fas fa-parking'></i>
<span>Available</span>
</div>
#endif
</div>
<div class="name-icon">
#if ($rentalhse->generator == 'yes')
<span>Backup Generator</span>
<div class="icon">
<i class="fa fa-bolt"></i>
<span>Available</span>
</div>
#endif
</div>
</section>
</div>
<div class="viewprice" style="display: flex;
justify-content: space-between; margin:0px !important;">
<section class="viewlink">
Contact Admin
</section>
<section class="viewlink">
<a class="btn-sm btn-warning" href="{{ url('rentalhse/'.$rentalhse->rental_slug.'/'.$rentalhse->id) }}" role="button" >
View Details
</a>
</section>
</div>
</section>
</div>
#endforeach
#endif
here its how it looks like in the page .here the paragraph starts getting itaicised which is a different style from the first one.. here is the other part here the column gets smaller different from the set one in the row.its been giving me headache i havent understood why its coming up.

How do I make the images show the same height? bootstrap 4

it shows up like that because my photo is not the same size, is there a solution for this problem?
enter image description here
here is the code:
<div class="features_items"><!--features_items-->
<h2 class="title text-center">Features Items</h2>
#foreach($products as $product)
<div class="col-sm-4 h-100">
<div class="product-image-wrapper ">
<div class="single-products h-100">
<div class="productinfo h-100 text-center">
<img src="{{$baseUrl . $product->feature_image_path}}" alt="" />
<h2>{{ number_format($product->price )}} VNĐ</h2>
<p>{{ $product->name }}</p>
<a href="#"
data-url="{{route('addToCart',['id'=> $product->id])}}"
class="btn btn-default add_to_cart">
<i class="fa fa-shopping-cart"></i>
Add to cart
</a>
</div>
<div class="product-overlay">
<div class="overlay-content">
<h2>{{ number_format($product->price )}} VNĐ</h2>
<p>{{ $product->name }}</p>
<button
data-url="{{route('addToCart',$product->id)}}"
class="btn btn-default add_to_cart"><i class="fa fa-shopping-cart"></i>Add to cart</button>
</div>
</div>
</div>
</div>
</div>
#endforeach
</div><!--features_items-->

How to make columns not dependent on each other with Bootstrap?

There is a menu on the left with the effect of the accordion, on the right content is formed with a jinja. I need to do so that the height of the menu and the contents do not depend on each other.
as here: click
HTML:
<!-- menu -->
<div class="col-md-3">
<div class="wrapper">
<h1 class="header-tabs">Brands</h1>
<div class="tab">
{% for brand in brands %}
<button value="{{ brand.id }}">{{ brand.brand_name }
</button>
{% endfor %}
</div>
</div>
</div>
<!-- content -->
{% for sm in smartphones %}
<div class="col-md-2">
<img class="photo-phone" height="150" width="150" src="{{ sm.photo.url }}">
</div>
<div class="col-md-5">
<h3 class="header-phone">{{ sm.brand }} {{ sm.model }}</h3>
<p descr-phone>{{ sm.description }}</p>
</div>
<div class="col-md-2">
<h4 class="price">{{ sm.price }}$</h4>
<input type="button" class="button-buy" value="Buy">
</div>
{% endfor %}
The usual way to achieve that is by nesting. Nesting must always be done using row-column pairs i.e. never nest a column directly inside another column.
So, in your case, you'd first create a column with the class col-md-9 then put a .row inside that column and then put all your content columns inside that newly created row.
Note that inside this newly created row you now have a total of 12 column units to work with.
Click "run code snippet" below and expand to full page for testing:
<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">
<!-- menu -->
<div class="col-md-3">
<div class="wrapper">
<h1 class="header-tabs">Brands:</h1>
<div class="tab">
<!-- {% for brand in brands %}-->
<button value="{{ brand.id }}">
<!-- {{ brand.brand_name }-->
Brand Name
</button>
<!-- {% endfor %}-->
</div>
</div>
</div>
<!-- content -->
<div class="col-md-9">
<div class="row">
<!-- {% for sm in smartphones %}-->
<div class="col-md-3 mb-3">
<!-- <img class="photo-phone" height="150" width="150" src="{{ sm.photo.url }}">-->
<img class="photo-phone img-fluid" src="https://placeimg.com/640/480/tech">
</div>
<div class="col-md-6">
<h3 class="header-phone">
<!-- {{ sm.brand }} {{ sm.model }}-->
Brand Model
</h3>
<p descr-phone>
<!-- {{ sm.description }}-->
Description
</p>
</div>
<div class="col-md-3 mb-3">
<h4 class="price">
<!-- {{ sm.price }}$-->
$1,000
</h4>
<input type="button" class="button-buy" value="Buy">
</div>
<div class="col-md-3 mb-3">
<!-- <img class="photo-phone" height="150" width="150" src="{{ sm.photo.url }}">-->
<img class="photo-phone img-fluid" src="https://placeimg.com/640/480/tech">
</div>
<div class="col-md-6">
<h3 class="header-phone">
<!-- {{ sm.brand }} {{ sm.model }}-->
Brand Model
</h3>
<p descr-phone>
<!-- {{ sm.description }}-->
Description
</p>
</div>
<div class="col-md-3 mb-3">
<h4 class="price">
<!-- {{ sm.price }}$-->
$1,000
</h4>
<input type="button" class="button-buy" value="Buy">
</div>
<div class="col-md-3 mb-3">
<!-- <img class="photo-phone" height="150" width="150" src="{{ sm.photo.url }}">-->
<img class="photo-phone img-fluid" src="https://placeimg.com/640/480/tech">
</div>
<div class="col-md-6">
<h3 class="header-phone">
<!-- {{ sm.brand }} {{ sm.model }}-->
Brand Model
</h3>
<p descr-phone>
<!-- {{ sm.description }}-->
Description
</p>
</div>
<div class="col-md-3 mb-3">
<h4 class="price">
<!-- {{ sm.price }}$-->
$1,000
</h4>
<input type="button" class="button-buy" value="Buy">
</div>
<!-- {% endfor %}-->
</div>
</div>
</div>
</div>
Also note the use of the spacing class mb-3 (margin-bottom 3 units).
The img-fluid class makes the images responsive.
Reference:
https://getbootstrap.com/docs/4.0/layout/grid/#nesting