show content from right to left in web (html and css) - html

I want to show the content in my website from right to left, I'm trying using Flex from bootstrap but still doesn't work, did javascript library like jquery needed to show content from right to left?
this is the look I want
enter image description here
this is my web look like
enter image description here
this is myhtml
<div class="container">
#foreach ($books as $book)
<div class="d-flex justify-content-center " style="width:150px; direction:rtl">
<div class="card bg-info mb-3" style="width: 18rem;">
<img src="{{ asset("img/books/$book->gambar") }}" width="150" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{ $book->judul }}</h5>
<a href="#" class="btn btn-primary" >detail</a>
</div>
</div>
</div>
#endforeach

Bootstrap has a .flex-row-reverse class that can be used to change the direction of a flex row. So you should be able to do something like this:
<div class="container">
<div class="d-flex flex-row-reverse">
#foreach ($books as $book)
<div class="justify-content-center" style="width:150px; direction:rtl">
<div class="card bg-info mb-3" style="width: 18rem;">
<img src="{{ asset('img/books/$book->gambar') }}" width="150" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{ $book->judul }}</h5>
<a href="#" class="btn btn-primary" >detail</a>
</div>
</div>
</div>
#endforeach
</div>
</div>

Related

how to show show db. data for all template using base template

hello I m new in Django I m creating a Django ecommerce project nd I created I slider in base template I want to show slider in all the template ..first template its working properly but if I go for some other template like section then its not showing images nd product name which I extends from base template ..hope some one help us .
base.html
<div class="container bg">
<div id="demo" class="carousel slide my-3" data-ride="carousel">
<ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
<li data-target="#demo" data-slide-to="1"></li>
<li data-target="#demo" data-slide-to="2"></li>
</ul>
<div class=" carousel-inner ">
<div class="carousel-item active">
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src="/media/{{cake.0.images}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{cake.0.prodname|title}}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src="/media/{{cake.1.images}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{cake.1.prodname|title}}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src="/media/{{ic.0.images}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{ic.0.prodname|title}}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src="/media/{{ic.1.images}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{ic.1.prodname|title}}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src="/media/{{pb.0.images}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{pb.0.prodname|title}}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src="/media/{{pb.1.images}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{pb.1.prodname|title}}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src="/media/{{bs.0.images}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{bs.0.prodname|title}}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src="/media/{{bs.1.images}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{bs.1.prodname|title}}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
</div>
</div>
</div>
<div class="carousel-item">
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src="/media/{{sauth.0.images}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{sauth.0.prodname|title}}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src="/media/{{ind.0.images}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{ind.0.prodname|title}}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src="/media/{{inter.0.images}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{inter.0.prodname|title}}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
</div>
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src="/media/{{gj.0.images}}" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{gj.0.prodname|title}}</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
Go somewhere
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
that my base template where I define my db. data like images and product name
bengalisweet.html
<!doctype html> {%extends "myproj/base.html" %} {% block title_block %}bengali sweet {%endblock%}{%load static %} {% block body_block %}
<div id="product">
<div class="hd">
<h1>Best Bengali Sweet Listed Here</h1>
</div>
</div>
<div class="container" xmlns:data="http://www.w3.org/1999/xhtml">
<div id="demo" class="carousel slide my-3" data-ride="carousel">'
<ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
{% for i in range %}
<li data-target="#demo" data-slide-to="{{i}}"></li>
{% endfor %}
</ul>
<!-- slideshow starts here-->
<div class="carousel-inner">
<div class="carousel-item active">
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src='/media/{{product.0.images}}' class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{product.0.prodname|title}}</h5>
<p class="card-price">{{product.0.price}}</p>
<p class="card-text">{{product.0.desc|truncatewords:10|title|linebreaks}}</p>
<div class="btn2">
<button type="button" class="btn btn-primary">Order Now</button>
<button type="button" class="btn btn-danger cart">Add to Cart</button>
</div>
</div>
</div>
</div>
{% for i in product|slice:"1:" %}
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src='/media/{{i.images}}' class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{i.prodname|title}}</h5>
<p class="card-price">{{i.price}}</p>
<p class="card-text">{{i.desc|truncatewords:10|title|linebreaks}}</p>
<div class="btn2">
<button type="button" class="btn btn-primary">Order Now</button>
<button type="button" class="btn btn-danger cart">Add to Cart</button>
</div>
</div>
</div>
</div>
{% if forloop.counter|divisibleby:3 and forloop.counter > 0 and not forloop.last %}
</div>
<div class="carousel-item">
{% endif%} {% endfor %}
</div>
</div>
</div>
<a class="carousel-control-prev " href="#demo" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#demo" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
{%endblock%}
that is my child template I want to show my slider for all the existing templates
make sure you passed the data alongside the html template in all the views and not just the base.html view
data = SomeModel.objects.all()
context = {"data":data}
return render(request, 'example.html', context)

Bootstrap5 Stretched-link doesn't work with a simple card

I have a small problem, stretched-link doesn't want to work with my card, I tried everything from Bootstrap docs. Tried also removing buttons cause I've read that they don't "live well" with stretched-link. I use django-bootstrap-v5 (is it good to use this btw.?)
This is my code:
<div class="card mb-3" style="width: 81rem;">
<div class="row g-0">
<div class="col-md-4">
<a type="button" class="streched-link" href="{% url 'bloger:post' post.id %}">
<img class="img-fluid" src="...">
</a>
</div>
<div class="col-md-8" style="max-height: 11rem;">
<div class="card-header d-flex bd-highlight">
<small class="text-muted p-1 flex-grow-1">Added {{ post.date_added|timesince:currentdate}} ago.</small>
<small class="text-muted p-1 flex-grow-3">Komentarze: {{ post.blogcomment_set.count }}</small>
</div>
<div class="card-body" style="max-height: 10rem;">
<h4 class="card-title">{{post.title|title}}</h4>
<p class="card-text" style="max-height: 8.4rem;"><i>{{post.truncated_text}}</i></p>
<a class="streched-link btn btn-danger" href="{% url 'bloger:post' post.id %}">Read more</a>
</div>
</div>
</div>
</div>
you are miss-spelling stretched

How to center last two cards in bootstrap?

I write application in angular, using bootstrap. I want the last 2 cards to be in the middle, instead of to the left. Now it looks like one last card is missing. I want to correct it. How to do it?
html code:
<div class="container" style="padding-top:1.1cm">
<div class="card-columns">
<div class="card text-center" [routerLink]="['/special/arrangements-salon']">
<div class="card-body">
<img [src]="salon" height="100" width="100"><br><label>
<h5 style="padding-top:6mm">salon</h5>
</label>
</div>
</div>
<div class="card text-center" [routerLink]="['/special/arrangements-study']">
<div class="card-body">
<img [src]="study" height="100" width="100"><br><label>
<h5 style="padding-top:6mm">gabinet</h5>
</label>
</div>
</div>
<div class="card text-center" [routerLink]="['/special/arrangements-bedroom']">
<div class="card-body">
<img [src]="bedroom" height="100" width="100"> <br><label>
<h5 style="padding-top:6mm">sypialnia
</h5>
</label>
</div>
</div>
<div class="card text-center" [routerLink]="['/special/arrangements-kitchen']">
<div class="card-body">
<img [src]="kitchen" height="100" width="100"> <br><label>
<h5 style="padding-top:6mm">kuchnia
</h5>
</label>
</div>
</div>
<div class="card text-center" [routerLink]="['/special/arrangements-bathroom']">
<div class="card-body">
<img [src]="bathroom" height="100" width="100"><br><label>
<h5 style="padding-top:6mm">łazienka</h5>
</label>
</div>
</div>
</div>
</div>
add d-flex align-items-center justify-content-center to parent => card-columns div or you can add mx-auto to last div
<div class="container" style="padding-top:1.1cm">
<div class="card-columns d-flex align-items-center justify-content-center">
<div class="card text-center" [routerLink]="['/special/arrangements-salon']">
<div class="card-body">
<img [src]="salon" height="100" width="100"><br><label>
<h5 style="padding-top:6mm">salon</h5>
</label>
</div>
</div>
<div class="card text-center" [routerLink]="['/special/arrangements-study']">
<div class="card-body">
<img [src]="study" height="100" width="100"><br><label>
<h5 style="padding-top:6mm">gabinet</h5>
</label>
</div>
</div>
<div class="card text-center" [routerLink]="['/special/arrangements-bedroom']">
<div class="card-body">
<img [src]="bedroom" height="100" width="100"> <br><label>
<h5 style="padding-top:6mm">sypialnia
</h5>
</label>
</div>
</div>
<div class="card text-center" [routerLink]="['/special/arrangements-kitchen']">
<div class="card-body">
<img [src]="kitchen" height="100" width="100"> <br><label>
<h5 style="padding-top:6mm">kuchnia
</h5>
</label>
</div>
</div>
<div class="card text-center" [routerLink]="['/special/arrangements-bathroom']">
<div class="card-body">
<img [src]="bathroom" height="100" width="100"><br><label>
<h5 style="padding-top:6mm">łazienka</h5>
</label>
</div>
</div>
</div>
</div>
Bootstrap card-columns uses CSS multi columns and for various reason it's not really possible to center items, or align rows differently.
Instead of using card-columns, use the grid (row > col-*), but you should note this won't give you a masonry layout or top-to-bottom ordering.

Bootstrap cards under each other

Now i have this:
<div class="row row-cols-1 row-cols-md-2 g-4">
{{#each stories}}
<div class="col">
<div class="card shadow-sm">
<img class="card-img-top" src="{{ image }}">
<div class="card-body">
<p class="card-text">{{ description }}</p>
<div class="d-flex justify-content-between align-items-center">
Читать
<small class="text-muted">author</small>
</div>
</div>
</div>
</div>
{{/each}}
</div>
And it looks like:
Now
I want the cards to be under each other: Reference
if you wanna put every card under each other you should put w-100 to each of cards or change your code like this :
<div class="row g-4">
{{#each stories}}
<div class="col-lg-12 mx-auto">
<div class="card shadow-sm">
<img class="card-img-top" src="{{ image }}">
<div class="card-body">
<p class="card-text">{{ description }}</p>
<div class="d-flex justify-content-between align-items-center">
Читать
<small class="text-muted">author</small>
</div>
</div>
</div>
</div>
{{/each}}
</div>

How do I position text on the bottom of an image overlay in a card in Bootstrap 4

I am using Bootstrap 4 and cards with image overlay to put some text over the image. The text appears on the top of the image, while I want it to be at the bottom.
This is the html code for the cards:
<div class="card-deck">
{% for article in article_list|slice:":3" %}
<div class="card card-inverse align-self-center">
<div class="card-header text-center">
{{ article.category|capfirst }}
</div>
<img class="card-img" src="{% static article.image %}" alt="Card image cap">
<div class="card-img-overlay">
<h4 class="card-title">{{ article.title }}</h4>
</div>
</div>
{% endfor %}
Make the card-img-overlay display flex using d-flex, and then justify-content-end to align at the bottom..
<div class="card bg-inverse">
<div class="card-header text-center">
Category
</div>
<img class="card-img" src="//placehold.it/400" alt="Card image cap">
<div class="card-img-overlay h-100 d-flex flex-column justify-content-end">
<h4 class="card-title">Title</h4>
</div>
</div>
Demo: https://www.codeply.com/go/7tnRTddIh6
More on vertical align in Bootstrap 4
If you want to align overlay vertically the simplest solution is to add d-flex and align-items-end to card-img-overlay. This will move h3 to the bottom of the card
<div class="card bg-inverse">
<div class="card-header text-center">
Category
</div>
<img class="card-img" src="//placehold.it/400" alt="Card image cap">
<div class="card-img-overlay d-flex align-items-end">
<h4 class="card-title">Title</h4>
</div>
</div>
If you want you can read more about aligning items vertically in bootstrap look here:
Bootstrap 4 Align-items
On css-tricks.com you can find amazing guide how the flexbox behaves - check here:
A Complete Guide to Flexbox