I find some posts in Stack Overflow but it doesn't work for me. I need some specific help.
This is my board page :
When I type long title post, it looks like this :
As you can see here, it ruins each table cell's width, as well as text not being truncated.\
What I want to do :
If text reaches the end of title field, it should be truncated
Anything should not ruin the table format (width..etc)
Here is my html code (used in django):
{% extends 'chacha_dabang/skeleton/base.html' %}
{% block content %}
<div class="container inner">
<div class="row">
<div class="col-md-8 col-sm-9 center-block text-center">
<header>
<h1> 차차다방 게시판 </h1>
<p> 회원들의 게시글을 볼 수 있는 페이지 입니다.</p>
</header>
</div><!-- /.col -->
</div><!-- /.row -->
</div><!-- /.container -->
<div class="container inner-bottom">
<div class="table-responsive">
<table class="table">
<col width="65%">
<col width="15%">
<col width="13%">
<col width="7%">
<thead>
<tr>
<th>제 목</th>
<th>작성자</th>
<th>작성일</th>
<th>조회수</th>
</tr>
</thead>
<tbody>
{% for post in posts %}
<tr>
<td class="td-title-area"> {{ post.title}} </td>
<td> {{post.author}} </td>
<td> {{post.created_at|date:"SHORT_DATE_FORMAT"}} </td>
<td> 11 </td>
</tr>
{% endfor%}
</tbody>
</table>
</div>
<br>
<br>
{% if is_paginated %}
<div class="pagination text-center" style="position:center;">
<span class="page-links">
{% if page_obj.has_previous %}
previous
{% endif %}
<span class="page-current">
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
</span>
{% if page_obj.has_next %}
next
{% endif %}
</span>
</div>
{% endif %}
</div>
{% endblock %}
Need your helps. Thanks
Edit
Here is what I'm trying to do :
1. I made class named truncate and define css for it :
.truncate {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
And add truncate class to my table :
<tbody>
{% for post in posts %}
<tr>
<td class="td-title-area">
<a href="{{ post.get_absolute_url }}" class="td-title truncate">
{{ post.title}}
</a>
</td>
<td> {{post.author}} </td>
<td> {{post.created_at|date:"SHORT_DATE_FORMAT"}} </td>
<td> 11 </td>
</tr>
{% endfor%}
</tbody>
And result is :
You could try something like this:
.td-title-area {
position: relative;
}
.td-title-area a {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
<table class="table">
<col width="65%">
<col width="15%">
<col width="13%">
<col width="7%">
<thead>
<tr>
<th>제 목</th>
<th>작성자</th>
<th>작성일</th>
<th>조회수</th>
</tr>
</thead>
<tbody>
<tr>
<td class="td-title-area"> sdkjghbdslkjgbshdfjgbsdfjkhgbsdfjkghbsdgsdfhjkgbsdfkjhgbsdfkhjgbsdfkjghbsfdkjhg </td>
<td> author </td>
<td> date </td>
<td> 11 </td>
</tr>
<tr>
<td class="td-title-area"> sdkjg </td>
<td> author </td>
<td> date </td>
<td> 11 </td>
</tr>
</tbody>
</table>
Related
I have tried to make a page where one column is fixed and the other one is scrollable. In the template "Os name" and "{{ i.os_name }}", I want to make it fixed. All the other ones should be scrollable.
I have tried some solutions but I'm facing issues. I have pasted the CSS which I have tried. Please tell me where I am going wrong so I can make it correct.
<div>
<table class="table accountTable" id="book-table" cellpadding="0" cellspacing="0" style="width: 91%;">
<thead>
<tr class="accountBorder">
<th class="osfix">Os Name</th>
<th class="">Browser</th>
<th>IP Address</th>
<th>Location</th>
<th>Session Time</th>
<th>Activity</th>
</tr>
</thead>
<tbody>
{% for i in account %}
<tr>
<td><div class="osfixName">{{ i.os_name }}</div></td>
<td>
<div class = "title_elipses accordion">{{ i.browser }}</div>
<div class="panel" style="display: none;"><p>{{i.browser}}</p></div>
</td>
<td>
<div>{{ i.ip_address }}</div>
</td>
<td>
<div>{{ i.city }}, {{ i.country }}</div>
</td>
<td>
{% for key,value in some_date.items %}
{% if i.id == key %}
<!-- here we are displaying the age of the ad -->
<span class="dealpagetext">{{ value }}</span><br>
{% endif %}
{% endfor %}
<!-- <div>{{ i.last_loggedin }}</div>-->
</td>
<td>
{% if i.activity == 1 %}
<div>Signout</div>
{% else %}
<div></div>
{% endif %}
</td>
</tr>
{% empty %}
<tr>
<td colspan="7" class="text-center">No History</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
css
#book-table {
width: 131% !important;
margin-left: 111px;
}
.osfix {
position: fixed;
left: 0;
background-color: #ddd;
padding-left: 4px;
}
.osfixName {
position: fixed;
left: 0;
padding-left: 4px;
z-index: 88;
background-color: #fff;
}
Please find the attached print format for reference.I am using jinja to create print format.If the content is small,print will have large unwanted space.how can i increase the space of last row in a table dynamially according to page using html and css.
Please find code sample for table without any css.
<table class="table table-condensed table-hover table-bordered" style="font-size:13px;font-family: Arial, Helvetica, sans-serif;">
<tr>
<th>Sl.</th>
<th>Description</th>
<th class="text-right">Qty</th>
<th class="text-right">Unit Price</th>
<th class="text-right">Amount</th>
</tr>
{%- for row in doc.items -%}
<tr>
<td style="width: 2%;">{{ row.idx }}</td>
<td style="width: 73%;">{{ row.description_for_print or '' }}</td>
<td style="width: 2%; text-align: right;">{{ row.qty }}</td>
<td style="width: 13%; text-align: right;">
{{ row.get_formatted("rate", doc) or ''}}
<td style="width: 10%; text-align: right;">{{
row.get_formatted("amount", doc) or ''}}</td>
</tr>
{%- endfor -%}
{%- if doc.discount_amount -%}
<tr>
<td colspan="4">
<div class="row">
<div class="col-xs-12 text-left"><b>Total :</b></div>
</div>
</td>
<td style="width: 8%; text-align: right;"><b>{{ doc.get_formatted("total") or '' }} </b></td>
</tr>
<tr>
<td colspan="4">
<div class="row">
<div class="col-xs-12 text-left"><b>Discount :</b></div>
</div>
</td>
<td style="width: 8%; text-align: right;"><b>{{ doc.get_formatted("discount_amount") or '' }} </b></td>
</tr>
{%- endif -%}
<tr>
<td colspan="4">
<div class="row">
<div class="col-xs-12 text-left"><b>Net Total : {{ doc.base_in_words or '' }}</b></div>
</div>
<td style="width: 8%; text-align: right;"><b>{{ doc.get_formatted("grand_total") or '' }} </b></td>
</tr>
<tr>
<td colspan="4">
<div class="row">
<div class="col-xs-12 text-left"><b>50% Down Payment : {{ frappe.utils.money_in_words(x) or ''}}</b></div>
</div>
</td>
<td style="width: 8%; text-align: right;"><b>{{ "{:,.2f}".format(x) or 0.00 }} </b></td>
</tr>
<tr>
<td colspan="4">
<div class="row">
<div class="col-xs-12 text-left"><b>50% Upon Delivery : {{ frappe.utils.money_in_words(x) or ''}}</b></div>
</div>
</td>
<td style="width: 8%; text-align: right;"><b>{{ "{:,.2f}".format(x) or 0.00 }} </b></td>
</tr>
</tbody>
</table>
I am making a email template and inserting an python list with a forloop, the problem I am having is that now since I already designed the template with a I cant get right array to align perfectly with the left array and the right array is pushed down.
Showing the error image
The right array is pushed down.
I need to get the array fixed but not sure how to do it since if I change the template design it starts effecting the email.
<tr>
<td bgcolor="#FFFFFF" align="center" valign="top" style=
"padding: 10px;">
<table role="presentation" cellspacing="0" cellpadding=
"0" border="0" width="100%">
<tr>
<!-- Column : BEGIN -->
<td width="50%" class="stack-column-center" align=
"center">
<table role="presentation section" class=
"presentation-section" cellspacing="0"
cellpadding="0" border="0">
<tr>
<th style="text-align: center">
<h3 style=
" font-size:14px; font-weight:800; margin:0 0 10px; font-family:Helvetica;">
Tele companies
</h3>
</th>
</tr>
{% for comp, values in vis_domain.companies %}
<tr>
<td style="text-align: center">
<p style=
"margin:5px 0; font-size:14px; font-family:Helvetica;">
<span style="font-size:13px ;color:gray; ">{{ values.0 }}</span> {{ comp }}
</p>
</td>
</tr>
{% endfor %}
</table>
</td><!-- Column : END -->
<!-- Column : BEGIN -->
<td width="50%" class="stack-column-center" align=
"center">
<table role="presentation" class=
"presentation-section" cellspacing="0"
cellpadding="0" border="0">
<tr>
<th style="text-align: center">
<h3 style=
" font-size:14px; font-weight:800; margin:0 0 10px; font-family:Helvetica;">
Tags used in chats
</h3>
</th>
</tr>
{% for tags in vis_domain.tags %}
<tr>
<td style="text-align: center">
<p style="margin:5px 0; font-size:14px;font-family:Helvetica;">
<span style="font-size:13px ;color:gray;">{{ tags.tag_count }}</span> {{ tags.name }}
</p>
</td>
</tr>
{% endfor %}
</table>
</td><!-- Column : END -->
</tr>
</table>
</td>
</tr><!-- 2 Even Columns : END -->
You need to add a style to the td's and specify the vertical alignment.
Try editing the first td after the 2 <!-- Column : BEGIN --> comments like this:
<td width="50%" class="stack-column-center" align="center" style="vertical-align: top;">
i want to add gap betweenw my input boxes in input form.
They are heavily packed together and not looking good.
so that the input form looks and feels good...form is a object passed from views.py....
createcustomer.html
{% extends 'customer/base.html' %}
{% block title %}Create Customer{% endblock %}
{% block body %}
<div class="container-fluid" style="background-color: #f2f2f2; width:100%; height:135%;" >
<div class="row ">
<div class="col-lg-4"></div>
<div class="col-lg-8 text-left" align="center">
<h2>Create a Customer</h2>
<form action="." method="post">
<div class="form-group" >
{% csrf_token %}
<table>
<tr style="width:100%;" class="highlight">
<td>First Name:</td>
<td>{{form.fname}}</td>
</tr>
<tr>
<td>Last Name:</td>
<td>{{form.lname}}</td>
</tr>
<tr>
<td>Email:</td>
<td>{{form.email}}</td>
</tr>
<tr>
<td>Address:</td>
<td>{{form.address}}</td>
</tr>
<tr>
<td>City:</td>
<td>{{form.city}}</td>
</tr>
<tr>
<td>State:</td>
<td>{{form.state}}</td>
</tr>
<tr>
<td>Zip:</td>
<td>{{form.zip}}</td>
</tr>
<tr>
<td>Username:</td>
<td>{{form.uname}}</td>
</tr>
<tr>
<td>Phone:</td>
<td>{{form.phone}}</td>
</tr>
</table>
<div style="margin-left:200px; margin-top:20px;margin-bottom:20px">
<input type="submit" class="btn btn-success" value="Submit">
</div></div>
</form>
</div>
</div>
</div>
{%endblock%}
you can try with css:
table tr {
margin-bottom: 10px;
display: table;
}
add table to cellspacing & cellpadding
<table cellspacing="1" cellpadding="1">
You can apply padding to the input itself by applying a class and css:
HTML
<input id="padded" type="submit" class="btn btn-success" value="Submit">
CSS
#padded {
padding: 10px;
}
This will create space around the input form, giving it room to breath.
I have a value foo, and this code displays its properties correctly with the following code:
<div class="col-md-6">
<p> {{ foo.name }} </p>
<p visible = "foo.description"> {{ foo.description }}</p>
<p> {{foo.tags }} </p>
<p visible = "foo.instructions"> {{ foo.instructions }} </p>
</div>
It displays four paragraphs, each with the value of foo.property
However, when I add a table underneath:
<div class="col-md-6">
<p> {{ foo.name }} </p>
<p visible = "foo.description"> {{ foo.description }}</p>
<p> {{ foo.tags }} </p>
<p visible = "foo.instructions"> {{ foo.instructions }} </p>
<table class="table table-hover">
<thead>
<tr>
<th>File Name</th>
<th>File Type</th>
<th>File Size</th>
<th> 3D View </th>
</tr>
</thead>
<tbody>
<tr ng-repeat-start="file in foo.fileId">
<td> filler </td>
<td> filler </td>
<td> filler</td>
<td> filler </td>
</tr>
</tbody>
</table>
</div>
The values now show literally as {{ foo.description }} rather than showing the value. Why would adding a simple table mess that up?
Ah, I figured it out. You have an 'ng-repeat-start' but you never end it. You need to include an 'ng-repeat-end'. Or, just use the normal 'ng-repeat' and then you don't have to specify a start and an end. This works:
<div class="col-md-6">
<p> {{ foo.name }} </p>
<p visible = "foo.description"> {{ foo.description }}</p>
<p> {{ foo.tags }} </p>
<p visible = "foo.instructions"> {{ foo.instructions }} </p>
<table class="table table-hover">
<thead>
<tr>
<th>File Name</th>
<th>File Type</th>
<th>File Size</th>
<th> 3D View </th>
</tr>
</thead>
<tbody>
<tr ng-repeat="file in foo.fileId">
<td> filler </td>
<td> filler </td>
<td> filler</td>
<td> filler </td>
</tr>
</tbody>
</table>