Custom Invoice Table - html

I'm trying to edit our Shopify 'New Order Notification' email and create a custom table to organize the information a bit better.
It should look like this on desktop, but I'd like to have the totals lined up with the 'line price' column.
On mobile, it looks like this the totals aren't aligned and the 'totals' table doesn't have a 100% width.
I know I obviously need to add mobile queries, which I tried & removed, I just got tired of trying & brought my issue here.
What styles or edits should I make to make both tables 100% on desktop & mobile, and how do I align the totals with the last column of the top table?
Here's my CSS:
/* general styles */
.main-container {
width: 80%;
}
table, tr, td, th {
border-collapse: collapse;
}
table {
width: 100%;
}
/* table-1-items styles */
.table-1-headers {
background-color: #00a850;
color: white;
font-weight: bold;
border-bottom: 2px solid black;
}
.table-1-headers td {
height: 50px;
vertical-align: middle;
}
.left-justify {
text-align: left;
}
.center-justify {
text-align: center;
}
.header-item {
padding-left: 20px;
}
.item-image,
.item-title,
.item-sku,
.item-price,
.item-qty,
.total-line-price,
.header-item-price,
.header-qty,
.header-line-price {
padding-right: 20px;
}
.spacer {
height: 15px;
}
/* table-2-totals styles */
.table-2-totals {
border-top: 2px solid black;
}
.totals-row-1 {
padding-top: 15px;
}
.order-instructions {
font-weight: bold;
vertical-align: top;
padding: 10px 30px 5px 5px;
white-space: nowrap;
}
.order-instructions span {
background-color: yellow;
font-weight: normal;
}
.totals-header {
font-weight: bold;
text-align: right;
border-left: 2px solid black;
padding-left: 8px;
}
.totals {
text-align: right;
padding-right: 22px !important;
min-width:101px !important;
}
.subtotal-header,
.subtotal-input {
padding-top: 10px;
}
And my HTML:
<p>Hello {{ shop_name }},</p>
<p>{% if customer.name %}<b>{{ customer.name }}</b>{% else %}Someone{% endif %} placed a new order with your store, {{ date | date: "%b %d %I:%M%p" }}:</p>
<div class="main-container">
<table class="table-1-items">
<tr class="table-1-headers" >
<td colspan="2" class="header-item left-justify" >Item</td>
<td class="header-sku left-justify">SKU</td>
<td class="header-item-price center-justify">Item Price</td>
<td class="header-qty center-justify">Qty</td>
<td class="header-line-price center-justify">Line Price</td>
</tr>
{% for line in line_items %}
<tr class="item-line">
<td class="item-image center-justify"><img src="{{ line | img_url: 'thumb' }}" alt="Item Image" /></td>
<td class="item-title left-justify">{{ line.title }}</td>
<td class="item-sku left-justify">{{ line.sku | lowcase }}</td>
<td class="item-price center-justify">{{ line.price | money }}</td>
<td class="item-qty center-justify">{{ line.quantity }}</td>
<td class="total-line-price center-justify">{{ line.line_price | money }}</td>
</tr>
{% endfor %}
<tr class="spacer"></tr>
</table>
<table class="table-2-totals">
<tr class="totals-row-1">
<td rowspan="7" class="order-instructions">ORDER NOTE/SPECIAL INSTRUCTIONS<br><span>{{ note }}</span></td>
<td class="totals-header subtotal-header">Subtotal:</td>
<td class="totals subtotal-input">{{ subtotal_price | money }}</td>
</tr>
<tr>
<td class="totals-header">Tax:</td>
<td class="totals">{{ total_tax | money }}</td>
</tr>
<tr>
<td class="totals-header">Rate:</td>
<td class="totals">{{ tax_line.rate }}</td>
</tr>
<tr>
<td class="totals-header">Discounts:</td>
<td class="totals">{{ discounts_amount | money }}</td>
</tr>
<tr>
<td class="totals-header">Shipping:</td>
<td class="totals">{{ shipping_price | money }}</td>
</tr>
<tr>
<td class="totals-header">Total:</td>
<td class="totals">{{ total_price | money }}</td>
</tr>
</table>
</div>
<br>
<br>
View order {{order_name}}
<br>
{% if fulfillment_aborted %}
<p>The above order was not automatically fulfilled because it was flagged as suspicious.</p>{% endif %}
<br>
{% if has_high_risks? %}<p><b>Security check:</b></p>
<p>This order has a risk of being fraudulent. Review the order in your store's admin and contact the customer to verify their information.</p>
{% endif %}
<br>
<p><b>Customer Email: </b>{{ email }}</p>
<p><b>Customer Company: </b>{{ billing_address.company }}</p>
<br>
<p><b>Payment processing method:</b></p>
<p>{{ gateway }}</p>
<br>
{% if requires_shipping and shipping_address %}
<p><b>Delivery method:</b></p>
{% for shipping_method in shipping_methods %}<p>{{ shipping_method.title }}</p>{% endfor %}
<br>
<p><b>Shipping address:</b></p>
<p>{{ shipping_address.name }}</p>
<p>{{ shipping_address.street }}</p>
<p>{{ shipping_address.city }}, {{ shipping_address.province }} {{ shipping_address.zip }}</p>
<p>{{ shipping_address.country }}</p>
<p>{{ shipping_address.phone }}{% endif %}</p>
<br>
{% if shopify_shipping_enabled %}
<p>Save time and money by fulfilling with Shopify Shipping</p>
{% endif %}
Thanks in advance for any help!

So if tables have no defined height they will keep getting smaller until they can no longer get any smaller, then they stop where they are.
Add this to your CSS
table {
max-width: 800px;
min-width: 500px;
width: 100%;
}
All I'm doing there is telling the tables to be 100% wide, to a maximum of 800px, and a minimum of 500px. (adjust as required)
When you've added this you'll also want to remove the right paddding on the totals for MOBILES
.totals {
padding-right: 0 !important;
}
You also have a style called .main-container which has a max width of 80%... you need to replace that with
.main-container {
width: 100%;
}

Related

Basic Help in HTML

I just needed some help in HTML for a project. In our project, we have various html files that represent different pages of the same website. There is one "outline" html file and the other files extend this main template. In each html file, it generates a table(sometimes many tables) holding some data. My task is to add a button that can download the table if clicked on. How do I write HTML code that automatically puts the button next to each table when generated. (i.e if 4 tables were generated there should be 4 buttons, if there are 3 tables there should be 3 buttons). I have already got the code for the button and its image, but I do not really know how to do the task I described. I am quite new to this language so any type of help or a pointer in the right direction would be helpful!
I have placed the code for the button(its shape, logo, and color) in the "layout" html file, the file which is getting extended by all other html files in our project
This is the code that is in the template html file:
<style>
.button{
position: absolute;
left: 100px;
top: 150px;
height: 40px;
width: 40px;
padding: 0;
background : #fff;
border: none;
outline: none;
border-radius: 0px;
overflow: hidden;
font-size: 30px;
font-weight: 500;
}
.button:hover{
background: #D4D7D9
}
.button:active {
background: #D4D7D9
}
.button__icon {
align-items: center;
padding: 0px;
color: #000;
height: 100%;
}
</style>
<button type="button" class="button">
<span class="button__icon">
<ion-icon name="cloud-download-outline"></ion-icon>
</span>
</button>
This is the code for the html file in which it only requires one button because there is only one table that gets generated max. Once again, it extends the template html code which was just displayed above.
<table id="data" class="table table-striped">
<thead>
<tr>
<th>Pokemon</th>
<th>Defense</th>
<th>Attack</th>
</tr>
</thead>
<tbody>
{% for key in data %}
<tr>
<td>{{ key }}</td>
<td>{{ data[key][0] }}</td>
<td>{{ data[key][1] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
And this is the code for the html pages that require multiple tables to be generated, and for as many tables there needs to be one corresponding button. The button should be in the same place relative to each table.
{% block script %}
<script>
function toggleTable(event) {
// get the click event
let element = event.target;
console.log(element)
// get the table
let table = document.getElementById(element.innerHTML);
console.log(table)
// get the current value of the table's display property
let displaySetting = table.style.display;
// now toggle the table depending on current state
if (displaySetting == 'inline-table') {
// table is visible. hide it
table.style.display = 'none';
}
else {
// table is hidden. show it
table.style.display = 'inline-table';
}
}
</script>
{% endblock %}
{% block main %}
<h1>Further Pokemon Breakdown</h1>
{% for key in data %}
<h3 onclick="toggleTable(event)">{{ key }}</h3>
<table class="table table-striped table-hover border-bottom" id={{ key }} style="display: inline-table;">
<thead>
<tr>
<th>Pokemon</th>
<th>Attack</th>
<th>Defense</th>
</tr>
</thead>
<tbody>
{% for key2 in data[key] %}
<tr>
<td>{{ key2 }}</td>
<td>{{ data[key][key2][0] }}</td>
<td>{{ data[key][key2][1] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endfor %}
Thanks for the help!!!

HTML/CSS : justify - center and align two icons in a cell of a table

His guys,
I have this table with two icons in the last column. I would like that the icons are next to each, align and with a nice space in the cell. What are the parameters required for that ? I tried with justify-content and margin but it stays like that.
Thank you
Here is my result :
How can I correct that ?
Here is the code html :
{% block content %}
<link rel="stylesheet" href="{% static 'test15.css' %}">
<div class="upload-app">
<div class="upload-in">
<h2>Upload</h2>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form.as_p }}
<button type="submit">Upload</button>
</form>
{% if url %}
<p>Uploaded files : {{url}}</p>
{% endif %}
</div>
<div class="listfiles">
<h2>Files Uploaded</h2>
<table id="customers">
<tr>
<th>Filename</th>
<th>Date</th>
<th>Size</th>
<th>Actions</th>
</tr>
{% for file in files %}
<tr>
<td>{{ file.Filename }}</td>
<td>{{ file.Uploaded_at | date:'d.m.Y H:i'}}</td>
<td>{{ file.SizeFile | filesizeformat}}</td>
<td>
<a href="{% url 'download' file.Id %}">
<i class='bx bxs-download'></i>
</a>
<a href="">
<i class='bx bxs-file-pdf' ></i>
</a>
</td>
</tr>
{% endfor %}
</table>
</div>
</div>
{% endblock %}
Here the css :
.listfiles{
margin-top: 20px;
border-radius: 12px;
background-color: #11101d;
color: #fff;
transition: all 0.5s ease;
width: 800px;
height: 600px;
}
.listfiles h2{
display: flex;
justify-content: center;
font-size : 26px;
padding-bottom: 20px;
padding-top: 30px;
margin-left: 25px;
}
.listfiles #customers{
border-collapse: collapse;
width: 100%;
}
#customers td{
border: 1px solid #ddd;
padding: 8px;
font-size: 12px;
}
#customers a{
color: #fff;
font-size: 14px;
justify-content: center;
display: flex;
row-gap: 3px;
}
#customers th {
border: 1px solid #ddd;
padding: 8px;
font-size: 14px;
}
#customers tr:nth-child(even){background-color: #272730b6;}
#customers tr:hover {background-color: rgb(83, 78, 78);}
#customers th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #0a0911;
color: white;
}
Can you please add class to your icon <td class="iconsColumn">
{% for file in files %}
<tr>
<td>{{ file.Filename }}</td>
<td>{{ file.Uploaded_at | date:'d.m.Y H:i'}}</td>
<td>{{ file.SizeFile | filesizeformat}}</td>
<td class="iconsColumn">
<a href="{% url 'download' file.Id %}">
<i class='bx bxs-download'></i>
</a>
<a href="">
<i class='bx bxs-file-pdf' ></i>
</a>
</td>
</tr>
{% endfor %}
Than in your css add flexBox to that class.
.iconsColumn{
display: flex;
flex-direction: row;
justify-content: center;
gap:1rem
}
https://www.w3schools.com/csS/css3_flexbox_container.asp
You can add a parent div to both of those icons and target that div to style it using display:flex
<td>
<div class="icons"
<a href="{% url 'download' file.Id %}">
<i class='bx bxs-download'></i>
</a>
<a href="">
<i class='bx bxs-file-pdf' ></i>
</a>
</div>
</td>
And for the css:
.icons{
display: flex;
justify-content : space-around
}

How to change div content based on screen size

I would like to change the content of the row divs inside the indices_container when the screen becomes small. Currently, on all screen sizes, each row shows the index name, price, 1-day change, and ytd change. I would only like to show the index name and ytd change on small screens.
I am only using Flask and bootstrap to serve my application so I am not even sure if this is even possible without something like react and vue. Can this be done with #media or browser JS?
index.html file:
{% extends 'base.html' %}
{% block body %}
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
{{message}}
</div>
{% endfor %}
{% endif %}
{% endwith %}
<div class="indices-container">
<div class="row">
{% for index in total_payload.get('indexes').get('meta_data') %}
<div class="col-sm-2 text-center">
{% set d = total_payload.get('indexes').get(index) %}
{{ "{} ${:.2f}".format(index, d['current_price']) }}
{{ "{:0.2f}% 1-Day".format(d['percent_change']) }}
{{ "{:0.2f}% YTD".format(d['ytd_percent_change']) }}
</div>
{% endfor %}
</div>
</div>
<div class="sp500-table-container">
<div class="table-responsive" id="sp500Table">
<table class="table table-light table-striped table-sm" id="sp500Table">
<thead class="thead-light">
<tr> {% for col in total_payload.get('companies').get('meta_data') %}
<th>{{ col }}</th>
{% endfor %}
</tr>
</thead>
<tbody> {% for num, r in enumerate(total_payload.get('companies').get('sp500companies')) %}
<tr>
<td>{{ num+1 }}</td>
<td>{{ r.get('Symbol') }}</td>
<td>{{ r.get('Security') }}</td>
<td>link</td>
<td>{{ r.get('Sector') }}</td>
<td>{{ r.get('SubSector') }}</td>
<td>{{ r.get('Headquarters') }}</td>
<td>{{ r.get('DateFirstAdded') }}</td>
</tr> {% endfor %}
</tbody>
</table>
</div>
</div>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p.name-price").css("color", "red");
});
});
</script>
{% endblock %}
style.css file:
html {
font-family: Arial, Helvetica, sans-serif;
}
body {
/* padding-bottom: 80px; */
/* height: 100% */
}
main {
/* display: flex; */
/* flex-direction: column; */
/* flex-grow: 1; */
padding-bottom: 80px;
overflow: hidden;
}
footer {
padding-top: 80px;
}
.indices-container {
margin: auto;
}
.sp500-table-container {
height: 70vh;
width: 100vw;
overflow: auto;
position: relative;
padding-bottom: 16px;
margin: auto;
/* flex: 1; */
/* margin-bottom: 16px; */
}
This is done with css native Media Queries, no additional libraries needed.
It would look something like this:
#media (max-width: 400px){
.indicie-payment { display: none; }
...
}
BUT
Since you said you are already using Bootstrap, you can use some utility classes for display that are already provided by Bootstrap
In your case you would need to wrap some of your items in an element like div or span and use a utility class like d-sm-none
So it might look something like this:
<div class="indices-container">
<div class="row">
{% for index in total_payload.get('indexes').get('meta_data') %}
<div class="col-sm-2 text-center">
{% set d = total_payload.get('indexes').get(index) %}
<span class="d-sm-none">{{ "{} ${:.2f}".format(index, d['current_price']) }}</span>
<span class="d-sm-none">{{ "{:0.2f}% 1-Day".format(d['percent_change']) }}</span>
{{ "{:0.2f}% YTD".format(d['ytd_percent_change']) }}
</div>
{% endfor %}
</div>
</div>

Two tables currently vertically top and bottom, would prefer them to be side to side

I'm reasonaly new to html and css, I am developing a simple web app in flask.
I'm trying to edit the homepage home.html, which inherits from layout.html.
I would like the bottom table (with the green and red circles) to be on the right of the main table above it. Ideally I could define the amount of space each takes in the container i.e. the left table takes up 65% and the right 35%. The tables would extend vertially the length of the page.
Thank you
layout.html
...
table {border-collapse: collapse; width: 100%; border: none;}
/*table {border-collapse: collapse; width: 100%; margin-bottom: 2em; border: none;}*/
td { border: none; padding: 0.5em 0; font-size: 20px; vertical-align: top;}
thead { text-transform: uppercase; font-weight: 700; border-bottom: 1px solid #ea560d;}
thead td { font-size: 20px; letter-spacing: 0.3px;}
tbody tr { border-bottom: 1px solid #a8a8a8;}
.leftside .rightside{
height:100vh;
width:95%;
}
.leftside{
background:white;
overflow:hidden;
}
.rightside{
background:black;
width:220px;
margin-left:30px;
float:right;
}
</style>
<body>
<section class="container">
{% block content %}{% endblock %}
</section>
</body>
</html>
home.html
{% block content %}
<div style="leftside">
<p align="right">
<a class="btn btn-primary" class="nav-item nav-link" href="{{ url_for('new_post') }}" role="button"
>New Post</a>
<a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button"
aria-expanded="false" aria-controls="collapseExample">Quick Expand</a>
</p>
<table style="leftside" align="center">
<tr style="border-bottom:1pt solid black;">
<th>Title</th>
<th>Status</th>
<th>Datetime</th>
<th>Assigned To</th>
<th>Reported By</th>
<th>Edit</th>
</tr>
{% for post in posts %}
<tr>
<td><a class="article-title" href="{{ url_for('post', post_id=post.id) }}">{{ post.title }}</a></td>
<td>{{ post.status }}</td>
<td><strong><small>{{ post.date_posted }}</small></strong></td>
<td><small>{{ post.assigned_to }}</small></td>
<td><small>{{ post.reported_by }}</small></td>
<td><a class="btn btn-primary" class="article-title" href="{{ url_for('update_post', post_id=post.id) }}">Edit</a></td>
</tr>
<td colspan="5">
<div class="collapse" id="collapseExample"><div class="card card-body">{{ post.description }}</div></div>
</td>
{% endfor %}
</table>
</div>
<div style="rightside">
<table>
{% for buggy in buggies %}
<tr>
{% if buggy['BRider'] %}
<td><svg height="40" width="40">
<circle cx="14" cy="14" r="12" stroke="black" stroke-width="3" fill="red" />
Sorry, your browser does not support inline SVG.
</svg></td>
{% else %}
<td><svg height="40" width="40">
<circle cx="14" cy="14" r="12" stroke="black" stroke-width="3" fill="green" />
Sorry, your browser does not support inline SVG.
</svg></td>
{% endif %}
<td>{{ buggy['BName'] }}</td>
<td>{{ buggy['BRider'] }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endblock content %}
Above code is not functional to the fullest to recreate it however this snippet will help you to how you can achieve the requested work:
flex got one of these features which helps developer not to break head to do these alignment since the property of flex will take care of both rows and columns.
In the below snippet you can change in the parent property of flex-direction:row/column; to see the difference in the alignment.
.Blocks{
display:flex;
flex-direction:row; /* change here(row/column) to see the difference */
padding:5px;
border:2px solid yellow;
width:650px;
}
#First{
border:2px solid blue;
height:450px;
width:300px;
margin:5px;
}
#Second{
border:2px solid red;
height:450px;
width:300px;
margin:5px;
}
<div class="Blocks">
<div id="First">
First
</div>
<div id="Second">
Second
</div>
</div>
Try using float : left attribute.
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
table{
width : 50%;
float : left;
}
</style>
</head>
<body>
<h1>The table element</h1>
<table>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
<table >
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
</body>
</html>
Here is the working example Click Here!

Shadow on dynamic line of table

I'm trying to put a shadow on each one of my table lines. But it's not working with the first one and I don't really understand why.
I put you the css inline as you can see the all things
{% for resultat in resultats %}
<tr style="background-color: #F0F0F0; box-shadow: 8px 8px 12px #aaa, 8px -8px 12px #aaa; -webkit-box-shadow: 8px 8px 12px #aaa;"
id="first_{{ nb }}>
<td>
<span class="fl marginTop8">
{{ resultat.missions.getDateReaPrev()|date('Y-m-d') }}
</span>
</td>
<td></td>
<td></td>
<td>
<span class="fl marginTop8">
{{ resultat.distance }} Km
</span>
</td>
<td></td>
<td class="badge fr" style="color: darkorange;">{{ resultat.nb_pdv }}</td>
</tr>
<tr style="background-color:white">
<td colspan="6"></td>
</tr>
{% endfor %}
Here is what I got with this code:
As you can see, the shadow is on the right both tr...but the border is only on the last tr.
I would like to get something like this one
Thanks for your help.
EDIT: For more precision there is a class tableEnquete on the table.
So there is too
.tableEnquetes tr:nth-child(2){ position:relative }
.tableEnquetes table{
border-radius: 0 0 15px 0;
box-shadow: 3px 3px 3px #AAA;
margin: 0;
table-layout: fixed;
}
Here is a fiddle of this problem: https://jsfiddle.net/wdwgn7ta/
You only need to change background-color:white to background-color:none
<tr style="background-color:none">
<td colspan="6"></td>
</tr>