I give the products to the page with the loop in the template, but there is a problem. There is a gap on the page and I can't find the reason. Most likely because of HTML codes. I will be glad if you help.
This gap in the middle
products.html
<!-- STORE -->
<div id="store">
<!-- row -->
<div class="row">
<!-- Product Single -->
{% for product in products %}
{% if product.available %}
<div class="col-md-4 col-sm-6 col-xs-6">
<div class="product product-single">
<div class="product-thumb">
<div class="product-label">
<span>New</span>
{% if product.sale %}
<span class="sale">-{{product.sale}}%</span>
{% endif %}
</div>
<button class="main-btn quick-view"><i class="fa fa-search-plus"></i> Göz At</button>
<img src="{{product.main_image.url}}" alt="">
</div>
<div class="product-body">
{% if product.sale %}
<h3 class="product-price">{{product.discount}} AZN <del class="product-old-price">{{product.price}} AZN</del></h3>
{% else %}
<h3 class="product-price">{{product.price}} AZN</h3>
{% endif %}
<div class="product-rating">
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star"></i>
<i class="fa fa-star-o empty"></i>
</div>
<h2 class="product-name">{{product.name}}</h2>
<div class="product-btns">
<button class="main-btn icon-btn"><i class="fa fa-heart"></i></button>
<button class="main-btn icon-btn"><i class="fa fa-exchange"></i></button>
<button class="primary-btn add-to-cart"><i class="fa fa-shopping-cart"></i> Səbətə At</button>
</div>
</div>
</div>
</div>
{% endif %}
{% endfor %}
<!-- /Product Single -->
</div>
<!-- /row -->
</div>
<!-- /STORE -->
Related
I am trying to display some plots(created with plotly) on my page, it works totally fine on localhost but when deployed on heroku the plots are not shown.
code to create plot in views.py
def icons(request, name):
l1 = testtable.objects.values()
d1 = []
d2 = []
for i in l1:
d1.append(i["d1"])
d2.append(i["d2"])
fig =px.bar(x=d1,y=d2)
photo = plotly.io.to_html(fig,config= {'displayModeBar': False})
fig2 = px.line(x=d1, y=d2)
photo1 = plotly.io.to_html(fig2,config= {'displayModeBar': False})
return render(request, 'icons.html', {'name':name,"photo":photo,"photo1":photo1})
code in icons.html
{% extends 'index.html' %} {% block content %}
<div class="content icon-content">
<div class="container icon-container">
<h3 class="icon-heading">Quick Launch</h3>
<div class="icon-bar">
<a class="active" href="#"><i class="fas fa-hand-pointer fa-2x"></i><span>Time In/Out</span></a>
<i class="fa-solid fa-copy fa-2x"></i><span>My Attendance Record</span>
<i class="fa-solid fa-calendar-minus fa-2x"></i><span>My Leave List</span>
<i class="fa-solid fa-file-invoice-dollar fa-2x"></i><span>My Payslips</span>
<i class="fa-solid fa-calendar-check fa-2x"></i><span>Apply Leave</span>
<i class="fa-solid fa-calendar-days fa-2x"></i><span>My Timesheet</span>
<i class="fa-solid fa-people-group fa-2x"></i><span>My Team</span>
</div>
</div>
<hr>
<div class="container icon-container">
<h3 class="icon-heading">Pending My Approval</h3>
<div class="icon-bar">
<a class="active" href="#"><i class="fa-solid fa-file-circle-check fa-2x"></i><span>Leave</span></a>
<i class="fa-solid fa-user-check fa-2x"></i><span>Attendance Regularization</span>
<i class="fa-solid fa-business-time fa-2x"></i><span>Timesheet</span>
</div>
</div>
<div>
{% if photo %} {{ photo|safe }} {% else %}
<p>No graph was provided.</p>
{% endif %}
</div>
<div>
{% if photo1 %} {{ photo1|safe }} {% else %}
<p>No graph was provided.</p>
{% endif %}
</div>
</div>
{% endblock %}
When run on heroku
When run on localhost
Sorry for this question, I hate CSS. It makes no sense to me.
I'm trying to overlay some text and a button on top of an image but it comes out of the image;
This is the code for the whole card;
<div class="col-md-6 col-lg-4 mb-4">
<div class="card listing-preview">
<h4 class="text-primary">{{ listing.title }}</h4>
<div>
<img class="card-img-top" src="{{ listing.map_url }}" alt="">
<div class="card-img-overlay">
<h2>
<span class="badge badge-secondary text-white">£{{ listing.price|floatformat }}</span>
</h2>
</div>
</div>
<div class="card-body">
<div class="listing-heading text-center">
<p>
<i class="fas fa-map-marker text-secondary"></i> {{ listing.city }} {{ listing.state }}, {{ listing.zipcode }}</p>
</div>
<hr>
<div class="row py-2 text-secondary">
<div class="col-6">
Bills Inc:   {% if listing.bills_inc %}
<i class="fas fa-check"></i> {% else %}
<i class="fas fa-times"></i> {% endif %}
</div>
<div class="col-6">
Deposit: {% if listing.deposit %} £{{ listing.deposit|floatformat }} {% else %}
<i class="fas fa-times"></i> {% endif %}
</div>
</div>
<div class="row py-2 text-secondary">
<div class="col-6">
<i class="fas fa-bed"></i> Type: {{ listing.type|title }}</div>
<div class="col-6">
<i class="fas fa-bath"></i> Bathrooms: {{ listing.bathrooms }}</div>
</div>
<hr>
<div class="row py-2 text-secondary">
<div class="col-12">
<i class="fas fa-user"></i> by {{ listing.advertiser_type }} {{ listing.advertiser_name|title }}</div>
</div>
<div class="row text-secondary pb-2">
<div class="col-6">
<i class="fas fa-clock"></i> {{ listing.list_date | timesince }}</div>
</div>
<hr>
More Info
</div>
</div>
</div>
Bonus points (upvote) if you can overlay 'London, N20' at the bottom of the map as well.
Thanks in advance.
You are looking for the z-index attribute:
#first {
width: 60px;
height: 60px;
background-color: red;
position: absolute;
z-index: 1;
}
#second {
width: 60px;
height: 60px;
background-color: green;
position: absolute;
left: 30px;
top: 30px;
}
<div id="first"></div>
<div id="second"></div>
The item having larger z-index will be displayed over the item having a lower z-index.
I have a dropdown menu using boostrap card that look like this :
I set z-index property to 1000 for the card div, position absolute. This card is in a horizontal menu at the top of my page with a position fixed. My body have a relative position and my div with the content of my page have a relative position too.
This is the render of my page :
And there is my HTML code :
<body>
<div id="body">
<div class="header">
<div class="row">
<div class="col-1 col-sm-1">
<button class="hamburger">☰</button>
</div>
<!--<div class="col-1 col-sm-1 col-lg-1 offset-lg-2" id="spanSearch">
<h4><span class="badge indigo hide">{# block badge_research %}{% endblock #}</span></h4>
</div>
<div class="col-2 offset-2 col-sm-2 offset-sm-3 col-md-2 offset-md-3 col-lg-2 offset-lg-3">
<div class="search d-inline pull-right">
</i>
<form class="form-inline waves-effect waves-light" id="form">
<input class="form-control tags" id="search" type="text" placeholder="Search" onkeydown="keyDown()">
</form>
</div>
</div>
!-->
<div class="col-7 col-sm-6 col-md-6 col-lg-6 offset-lg-5">
<ul class="list-inline pull-right downMenu inline">
<li class="nav-item dropdown btn-group">
<a class="nav-link" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="false"> {% if is_granted("IS_AUTHENTICATED_REMEMBERED") %} <img src="{{ asset('/Image/contact.png') }}" class="img-circle" width="50" height="50"> {% else %} {{ 'acreat.mailing.nav.account'|trans }} {% endif %}</a>
<div class="dropdown-menu top dropdown" no-escape aria-labelledby="dropdownMenu1">
<div class="card">
<div class="card-block">
<div class="container-fuild">
<div class="row">
<div class="col-3">
<img src="{{ asset('/Image/contact.png') }}" class="img-circle" width="200" height="112">
</div>
<div class="col-9">
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
{{ 'acreat.mailing.nav.myaccount'|trans }}
{{ 'acreat.mailing.nav.changepassword'|trans }}
{% if is_granted('ROLE_PREVIOUS_ADMIN') %}
{{'acreat.mailing.admin.impersonalisation'|trans}}
{% endif %}
</div>
</div>
<div class="card-footer text-center">
{{ 'acreat.mailing.nav.logout'|trans }}
{% else %}
{{ 'acreat.mailing.nav.login'|trans }}
</div>
{% endif %}
</div>
</div>
</div>
</li>
</ul>
<div class="search d-inline inline pull-right">
</i>
<form class="form-inline waves-effect waves-light" id="form">
<input class="form-control tags inline" id="search" type="text" placeholder="Search" onkeydown="keyDown()">
</form>
</div>
<div class="inline pull-right spanSearch">
<h5>{% block badge_research %}{% endblock %}</h5>
</div>
</div>
</div>
</div>
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
{% block navbar %}
<div class="sidebar blue-grey darken-4 no-escape" id="navbar">
<div class="user-box no-escape">
<a class="logo no-escape" href="/" title="Retour à l'accueil">
<img src ="https://www.acreat.com/sites/acreat.com/themes/acreat/images/logo.png" class="img-fluid text-center no-escape"></img>
</a>
<h5 class="text-center">{{ 'acreat.mailing.title.website'|trans }}</h5>
</div>
<div class="list-group panel no-escape" aria-expanded="true">
<i class="fa fa-dashboard margin-right"></i> <span>{{ 'acreat.mailing.nav.dashboard'|trans }}</span>
<i class="fa fa-tasks margin-right"></i><span>{{ 'acreat.mailing.nav.inbox'|trans }}<i class="fa fa-angle-down" id="wrapperArrow"></i></span>
<div class="collapse show no-escape" id="menu0">
<a href="/message/template/{{app.user.id}}" class="list-group-item no-escape" data-parent="#sidebar" aria-expanded="true">
<span>{{ 'acreat.mailing.nav.addmessage'|trans }}</span>
</a>
{%- set numberNotSent = doctrine.createQueryBuilder().select('COUNT(u.id)').from('CoreBundle:Message', 'u').where("u.status !='COMPLETED'")
.andWhere("u.account = " ~ app.user.id).andWhere("u.status !='SUBMITTED'").getQuery().getResult() -%}
<a href="/message/viewNotSent" class="list-group-item no-escape" data-parent="#sidebar" aria-expanded="true">
<span>{{ 'acreat.mailing.nav.messagenotsent'|trans }}
<span class="badge badge-primary badge-pill align-right">{{ numberNotSent[0][1] }}</span>
</span>
</a>
{%- set numberSent = doctrine.createQueryBuilder().select('COUNT(u.id)').from('CoreBundle:Message', 'u').where("u.status ='COMPLETED'")
.andWhere("u.account = " ~ app.user.id).getQuery().getResult() -%}
<a href="/message/viewSent" class="list-group-item no-escape" data-parent="#sidebar" aria-expanded="true">
<span>{{ 'acreat.mailing.nav.messagesent'|trans }}
<span class="badge badge-primary badge-pill align-right">{{ numberSent[0][1] }}</span>
</span>
</a>
<a href="/message/viewDraft" class="list-group-item no-escape" data-parent="#sidebar" aria-expanded="true">
<span>{{ 'acreat.mailing.nav.draft'|trans }}</span>
</a>
</div>
<i class="fa fa-list margin-right"></i> <span>{{ 'acreat.mailing.nav.mailinglist'|trans }}</span>
</i> <span>{{ 'acreat.mailing.nav.member'|trans }}</span>
{%- if is_granted('ROLE_ADMIN') -%}
<div id="adminBottom" class="no-escape">
<i class="fa fa-envelope margin-right"></i> <span >{{ 'acreat.mailing.nav.administration'|trans }}<i class="fa fa-angle-down" id="wrapperArrow2"></i></span>
<div class="collapse show no-escape" id="menu4">
{{ 'acreat.mailing.nav.administrationlist'|trans }}
{{ 'acreat.mailing.nav.administrationaccount'|trans }}
{{ 'acreat.mailing.nav.administrationnewsletter'|trans }}
{{ 'acreat.mailing.nav.administrationparameters'|trans }}
</div>
</div>
{%- endif -%}
</div>
</div>
{% endblock navbar %}
{%- endif -%}
<div id="content">
{% block body %}
{%- if app.user == false -%}
<main class="col-12 col-md-12 col-xs-12 col-lg-12 col-xl-12">
{%- else -%}
<main class="col-12 col-sm-12 col-md-12 col-lg-12 col-xl-12 ">
{%- endif -%}
{% block flashmessage %}
{% for flashMessage in app.session.flashbag.get('notice') %}
<div class="alert alert-success" role="alert">
{{ flashMessage }}
</div>
{% endfor %}
{% for flashMessage in app.session.flashbag.get('fail') %}
<div class="alert alert-danger" role="alert">
{{ flashMessage }}
</div>
{% endfor %}
{% for flashMessage in app.session.flashbag.get('success') %}
<div class="alert alert-success" role="alert">
{{ flashMessage }}
</div>
{% endfor %}
{% endblock flashmessage %}
{% block main %}
{%- block breadcrumb -%}{%- endblock -%}
<section></section>
{%- block confirmation -%}{%- endblock -%}
{% endblock main %}
{% block fos_user_content %}
{% endblock fos_user_content%}
</main>
{% endblock body %}
</div>
</div>
</body>
Thanks for the help
You should set z-index for fixed parent element, not for card
Django with Bootstrap 3
I am working on a dashboard view for an FAQ system. I have set up the articles to be grouped by section. The section names are the headers in a list-group that when clicked will expand another list-group containing all the articles related to that group.
The issue that I am having is that I would like to set up the collapse to work like an accordion. I have followed bootstrap 3’s guide to accomplish this but when I click a new section open none of the prior open sections collapse close. I have exhausted other guides but the code looks correct yet the accordion functionality is not working.
My code:
{% block content %}
<div class="iron-faq">
<div class="container">
<div class="col-md-6">
<h3>Sections</h3>
<div class="list-group" id="accordion" aria-multiselectable="true">
{% regroup articles by section as section_list %}
{% for section in section_list %}
<a href="#section-{{ section.grouper.id }}"
class="list-group-item list-header"
data-toggle="collapse"
data-parent="#accordion"
data-target="#section-{{ section.grouper.id }}"
aria-controls="section-{{ section.grouper.id }}">
<i class="fa fa-bars"></i> {{ section.grouper }}
<span class="badge pull-right">{{ section.grouper.article_count }}</span>
</a>
<div class="panel-collapse collapse" id="section-{{ section.grouper.id }}">
{% for article in section.list %}
<a href="{{ article.get_absolute_url }}" class="list-group-item">
{{ article.title }}
</a>
{% endfor %}
</div>
{% endfor %}
</div>
</div>
<div class="col-md-6">
<h3>Useful Articles</h3>
<div class="list-group">
<div class="favorites">
{% for favorite in favorites %}
<a href="{{ favorite.get_absolute_url }}" class="list-group-item">
<h5 class="list-group-item-heading">{{ favorite.title }}</h5>
<p class="list-group-item-text">{{ favorite.section.name }}</p>
</a>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
{% endblock %}
You have to wrap each section with:
<div class="panel"></div>
So your html would look like the following:
{% block content %}
<div class="iron-faq">
<div class="container">
<div class="col-md-6">
<h3>Sections</h3>
<div class="list-group" id="accordion" aria-multiselectable="true">
{% regroup articles by section as section_list %}
{% for section in section_list %}
<div class="panel">
<a href="#section-{{ section.grouper.id }}"
class="list-group-item list-header"
data-toggle="collapse"
data-parent="#accordion"
data-target="#section-{{ section.grouper.id }}"
aria-controls="section-{{ section.grouper.id }}">
<i class="fa fa-bars"></i> {{ section.grouper }}
<span class="badge pull-right">{{ section.grouper.article_count }}</span>
</a>
<div class="panel-collapse collapse" id="section-{{ section.grouper.id }}">
{% for article in section.list %}
<a href="{{ article.get_absolute_url }}" class="list-group-item">
{{ article.title }}
</a>
{% endfor %}
</div>
</div>
{% endfor %}
</div>
</div>
<div class="col-md-6">
<h3>Useful Articles</h3>
<div class="list-group">
<div class="favorites">
{% for favorite in favorites %}
<a href="{{ favorite.get_absolute_url }}" class="list-group-item">
<h5 class="list-group-item-heading">{{ favorite.title }}</h5>
<p class="list-group-item-text">{{ favorite.section.name }}</p>
</a>
{% endfor %}
</div>
</div>
</div>
</div>
</div>
{% endblock %}
Hope this helps!
I have pasted a jsfiddle into my webpage and it doesn't work. Here is the jsfiddle. Pasted the CSS and javascript into the appropriaate places. There seem to be no errors on the console related to the link or popup.
All the link seems to do is to reload the current page.
Here is my HTML :
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-8">
<!-- POST -->
{% for entry in entries %}
<div class="panel panel-default">
<div class="panel-body">
<div class="media media-clearfix-xs-min">
<div class="media-left">
<a href="lesson.html">
<span class="media-object icon-block bg-default"><i class="fa fa-github"></i></span>
</a>
</div>
<div class="media-body">
<h3 class="media-heading h4">{{ entry.title }}</h3>
<p class="small text-muted">
<!-- <i class="fa fa-clock-o fa-fw"></i> time since post -->
Open PopUp
<div class="popup-box" id="popup-box-1">
<div class="close">X</div>
<div class="top">
<h2>Sample Header</h2>
</div>
<div class="bottom">
<p><h1>Sample Text</h1></p>
</div>
</div>
<i class="fa fa-user fa-fw"></i> {{entry.user_name}}
<i class="fa fa-calendar fa-fw"></i> {{entry.date_posted}}
</p>
{% for tag in entry.tagList %}
<span class="label label-default">{{tag}}</span>
{% endfor %}
</div>
</div>
</div>
</div>
{% else %}
<em>No entries!</em>
{% endfor %}
</div>
</div>
</div>
Sorry, here, I should have tested more.
I thought I had pasted the javascript in the right file, but I didn't. Once I pasted the js in the right file, it worked fine.