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.
Related
I have a Bootstrap page showing a title with 2 forms in a single row above a table. The 2nd form with the 2 inputs which appears in the top left above the table is taking up the full width of the parent column (col-md-8) - it only needs to take up around half of this column width.
I can't work out how to position this so it takes up less space but still aligns with the left of the title/table at the same time. Here's how it currently looks (make sure your use the full page option to see this as it will be used on desktop only):
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-md-8">
<h1>Items List</h1>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<form class="form-horizontal" id="findItems" action="#" method="get" role="form">
<input type="hidden" name="action" value="findItems">
<table class="table table-bordered">
<tr>
<td><input type="text" class="form-control" name="itemID" id="itemID" placeholder="Shipment ID"></td>
<td><input type="text" class="form-control datepicker" name="shippingDate" id="shippingDate" data-date-format="dd/mm/yyyy" placeholder="Date Shipped"></td>
<td class="text-center">
<button type="submit" class="btn btn-success">Update All</button>
</td>
</tr>
</table>
</form>
</div>
<!-- /.col-md-8-->
<div class="col-md-4">
<div>
<form class="form-horizontal" id="findMoreItems" action="#" method="get" role="form">
<input type="hidden" name="action" value="findMoreItems">
<table class="table table-bordered">
<tr>
<td>Shipment ID:</td>
<td><input type="text" class="form-control" name="shipmentID" id="shipmentID" placeholder="Shipment ID"></td>
</tr>
<tr>
<td>Authority ID:</td>
<td><input type="text" class="form-control" name="authorityID" id="authorityID" placeholder="Authority ID"></td>
</tr>
<tr>
<td>Ref ID:</td>
<td><input type="text" class="form-control" name="refID" id="refID" placeholder="Ref ID"></td>
</tr>
<tr>
<td>Serial Number:</td>
<td><input type="text" class="form-control" name="serialNumber" id="serialNumber" placeholder="Serial #"></td>
</tr>
<tr>
<td colspan="2" class="text-center">
<button type="reset" class="btn btn-default">Reset</button>
<button type="submit" class="btn btn-success">Search</button>
</td>
</tr>
</table>
</form>
</div>
</div>
<!-- /.col-md-4-->
</div>
<!-- /.row-->
<br>
<div>
<br />
<table class="table table-condensed table-striped table-bordered">
<thead>
<th class="text-center" scope="col">Shipment ID</th>
<th class="text-center" scope="col">Item ID</th>
<th class="text-center" scope="col">Serial Number</th>
<th class="text-center" scope="col">Shipped Date</th>
</thead>
<tbody>
</tbody>
</table>
</div>
</div><!-- /.container -->
You could always just add a spacer column. So...
<div class="col-md-6"> two table things </div>
<div class="col-md-2"> empty column for spacing </div>
<div class="col-md-4"> other table </div>
I am trying to align the Text Input to the right and for some reason it is not doing this.
I have used style="text-align: right" in <td>
See example:
https://jsfiddle.net/DTcHh/31200/
Code
<table class="table">
<thead>
<tr>
<th>Field 1</th>
<th style="text-align:right">Field 1</th>
</tr>
</thead>
<tbody>
<tr>
<td>Text 1</td>
<td style="text-align: right">
<div class="form-group" style="text-align: right">
<input style="width:60px" type="number" class="form-control" value="test">
</div>
</td>
</tr>
</tbody>
</table>
No extra CSS is needed just use Bootstrap pull-right:
https://jsfiddle.net/cp1tvuj3/
<div class="form-group">
<input style="width:60px" type="number" class="form-control pull-right" value="test">
</div>
Updated fiddle
text-right won't work because the form-control is display: block
The original question was for Bootstrap 3. In Bootstrap 4, pull-right is now float-right.
add inline-block to your div element, by default the div is a block element so it takes the complete width of its parent
<div class="form-group" style="text-align: right;display:inline-block;">
<input style="width:60px" type="number" class="form-control" value="test">
</div>
https://jsfiddle.net/RACCH/y9fvo4dj/
Seems like just adding float: right; does the trick, see
url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');
body {
margin: 10px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<table class="table">
<thead>
<tr>
<th>Field 1</th>
<th style="text-align:right">Field 1</th>
</tr>
</thead>
<tbody>
<tr>
<td>Text 1</td>
<td style="text-align: right">
<div class="form-group" style="text-align: right; float:right">
<input style="width:60px" type="number" class="form-control" value="test">
</div>
</td>
</tr>
</tbody>
</table>
Giving the div around the input field inside your td a style of
display:inline-block;
also fixes your problem without having any floats to potentially break other things.
https://jsfiddle.net/DTcHh/31202/
You need to add bootstrap class ie. "pull-right"
find the code fiddle :
`https://jsfiddle.net/DTcHh/31204/e`
These two solutions worked for me with a Bootstrap 4 table:
Either:
<td>
<div class="float-right">
<input>
</div>
</td>
Or:
<td class="text-right">
<div class="d-inline-flex">
<input>
</div>
</td>
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>
i tried putting my form inside the foreach so that the value passed in the form is the right value for the result not the last value. but the button inside the form is not submitting (nothing happens after clicking the button).
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Receiver's Name</th>
<th>Receiver's Contact</th>
<th>Package Type</th>
<th>Date Requested</th>
</tr>
</thead>
<tbody class="list">
#foreach($result as $res)
<form role="form" method="POST" action="/search ">
<input type="hidden" name="requestID" value="{{ $res->id }}">
<tr>
<td class="name"> {{ $res->receiverLname }},
{{ $res->receiverFname }}</td>
<td class="contact"> {{ $res->receiverContact }} </td>
<td class="type"> {{ $res->packType }} </td>
<td class="date"> {{ $res->updated_at }} </td>
<td><button class="btn"> View Transaction </button></td>
</tr>
</form>
#endforeach
</tbody>
</table>
nevermind guys. i just tried putting the value in the button instead in the input hidden type and im getting the right value in the post. :D
i get rid of the input type="hidden"
and make my button this way
<button class="btn" name="requestID" value="{{ $res->id }}">
The below code works for what I need (three horizontal buttons), except it is not centered. It sits on the left side of the screen. I did some research and couldn't fix it, and also tried a tableless design using "float" and "display:inline" and just can't get it centered. Help please!
<table>
<td>
<tr>
<form method="get" action="index.php"><button type="submit">Home</button></form>
<form method="get" action="signup"><button type="submit">Create Account</button></form>
<form method="get" action="login"><button type="submit">Login to Account</button></form>
</tr>
</td>
</table>
As other people mentioned <td> should be inside <tr>. By default <form> is displayed as block element. Change it to inline-block.
table {
border: 1px solid red;
width: 100%;
}
td {
border: 1px solid green;
text-align: center;
}
form {
display: inline-block;
}
<table>
<tr>
<td>
<form method="get" action="index.php">
<button type="submit">Home</button>
</form>
<form method="get" action="signup">
<button type="submit">Create Account</button>
</form>
<form method="get" action="login">
<button type="submit">Login to Account</button>
</form>
</td>
</tr>
</table>
The <tr> (rows) should be on the outside
<table>
<tr>
<td>
<form method="get" action="index.php"><button type="submit">Home</button></form>
</td>
<td>
<form method="get" action="signup"><button type="submit">Create Account</button></form>
</td>
<td>
<form method="get" action="login"><button type="submit">Login to Account</button></form>
</td>
</tr>
</table>
jsFiddle Demo
Inverse the tr and td in the html.
<table>
<tr>
<td>
<form method="get" action="index.php"><button type="submit">Home</button></form>
</td>
<td>
<form method="get" action="signup"><button type="submit">Create Account</button></form>
</td>
<td>
<form method="get" action="login"><button type="submit">Login to Account</button></form>
</td>
</tr>
</table>
And try adding this to css
td {
text-align: center;
}
And don't forget to set the width of your table ! (100% for all the window)