I have a table which contains data and I want the first footer item to be aligned left and the remaining ones to be aligned right.
Here is expected results:
table {
width: 100%
}
<table class="price-list">
<thead>
<tr>
<th>No</th>
<th>Nome</th>
<th>Quantidade</th>
<th>Preço</th>
</tr>
</thead>
<tbody>
<tr>
<td>text1</td>
<td>text2</td>
<td>text3</td>
<td>text4</td>
</tr>
</tbody>
<tfoot class="footer">
<tr align="left">
<td id="cart_voucher" class=" cart_voucher">
<form action="http://localhost:8080/index.php?controller=order-opc" method="post" id="voucher">
<div class="form-group form-group-placeholder">
<input type="text" class="discount_name form-control" id="discount_name" name="discount_name" placeholder="Kod rabatowy" value="">
<i class="fa fa-angle-right discount_icon" aria-hidden="true"></i>
<input type="hidden" name="submitDiscount">
</div>
</form>
</td>
</tr>
<!-- end VOUCHER -->
<!-- Total products -->
<tr align="right">
<td>Total products </td>
<td id="total_product">500,00 zł</td>
</tr>
<tr align="right">
<td Total shipping (tax incl.):>
</td>
<td id="total_shipping" class="price-opc">12,00 zł</td>
</tr>
<tr align="right">
<td>Total (tax excl.):</td>
<td id="total_price_without_tax" class="price-opc">418,50 zł</td>
</tr>
<!-- end Total tax excl. -->
<!-- Total tax -->
<tr align="right">
<td>Total tax:</td>
<td>93,50 zł</td>
</tr>
<!-- end Total tax -->
<tr align="right">
<td>Total:</td>
<td>
<span>512,00 zł</span>
</td>
</tr>
</tfoot>
</table>
I used inline align="left" for first footer element and align="right"for the remaining ones. I get the following:
UPDATE more explanation
In a footer we have form input and other data , form input should be left and the remaining footer element should be right as image describe below
I tried using flex-box for each tr but nothing worked. Can someone please help me? I just want the first element in the footer to align left and the rest to align right. Thanks, any help or suggestions will be helpful. Ignore thead and tbody, just consider tfoot.
You can apply float attribute for which accept right or left velues
.container {
width: 100%;
height: 100px;
background-color: red;
}
.left {
float: left;
background-color: yellow;
}
.right {
float: right;
background-color: yellow;
}
<div class="container">
<div class="left">Left Child</div>
<div class="right">Right Child</div>
</div>
This is how the attribute is work
Related
I am attempting to make my tables aligned, however the last table on the right wont align properly. I've tried using div and float. Those both do not work, or I may have not used it properly. How do I fix this? Im using different tables for each content because the cell padding looks odd.
#div1 {
float: left;
position: relative;
left: 450px
}
#div2 {
width: 20%;
float: center;
}
#div3 {
width: 20%;
float: right;
position: relative;
right: 400px
}
<div id="div1">
<table>
<tr>
<td><img src="https://cdn.discordapp.com/attachments/1016525603668762635/1023594193345581076/DEC_AVE.png" width=2 98 height=4 21 alt="Dec Ave"></th>
</tr>
<tr>
<td align="left" style="font-size:30px; color:rgb(10, 7, 96);" class="csize">DECEMBER AVENUE</td>
</tr>
<tr>
<td class="desc">LOCATION</td>
</tr>
<tr>
<td align=left class="dates">JUNE 28, 2022</td>
</tr>
<tr>
<td align=left><input class="buybutton" type="submit" value="Buy Tickets">
</tr>
</table>
</div>
<div id="div2">
<table>
<tr>
<td><img src="https://images1.smtickets.com/images/portrait_18082022203132.jpg" width=2 98 height=4 21 alt="TOMORROW X TOGETHER"></th>
</tr>
<tr>
<td align="left" style="font-size:30px; color:rgb(10, 7, 96);" class="csize">TOMORROW X TO...</td>
</tr>
<tr>
<td class="desc">LOCATION</td>
</tr>
<tr>
<td align=left class="dates">OCT 27-28, 2022</td>
</tr>
<tr>
<td align=left><input class="buybutton" type="submit" value="Buy Tickets">
</tr>
</table>
</div>
<div id="div3">
<table>
<tr>
<td><img src="https://images1.smtickets.com/images/portrait_12042022174844.jpg" width=2 98 height=4 21 alt="TOMORROW X TOGETHER"></th>
</tr>
<tr>
<td align="left" style="font-size:30px; color:rgb(10, 7, 96);" class="csize">RUSS THE JOURN...</td>
</tr>
<tr>
<td class="desc">LOCATION</td>
</tr>
<tr>
<td align=left class="dates">NOV 05, 2022</td>
</tr>
<tr>
<td align=left><input class="buybutton" type="submit" value="Buy Tickets">
</tr>
</table>
</div>
Try using
display: flex
flex-direction: column
on the three divs or try using
display: inline-block
It seems that what you really want is just a vertical alignment of the items (in other words, you don't really need a 'table', just items in a grid)
So in this case, use display:flex (flex boxes) on a <div> element and put all your items in it way. You also get rid of boilerplate for the table, tbody, tr and td. (It makes no sense to use a table but all table rows only have one element)
html like so:
<div id="container">
<div class="child-element">
<img ...>...</img>
...
</div>
<div class="child-element">
<img ...>...</img>
...
</div>
</div>
and css:
#container{
display: flex;
justify-content: center; /* centers everything */
}
.child-element{
/* add optional margins, paddings etc settings
}
This will make it responsive to how large the page is as well.
I'm showing a member who has a higher rank. Based on that, I have to show the user image along with the username.
but I'm not able to align the image and text efficiently..The problem is some username consists of a longer number of characters. As a result, the username showed in a zig-zag position..
so far, I've tried
<table style="width: 100%; table-layout: fixed" class="table table-striped text-center">
<thead class='bg-dark' style='background-color: 3658DE'>
<tr>
<th><img src='../assets/img/gold.png'/>Rank</th>
<th><i class='fa fa-user mr-1' style='color: #F4B806'></i>Members</th>
</tr>
<tr>
<td>
1
</td>
<td>
<div class='text-center'>
<img src='images' alt='user dp' class=' img-fluid rounded-circle' style='height: 30px; width: 30px;' />
<span class='mr-1 '>#$username</span>
</div>
<td>
</tr>
</thead>
<tbody>
Expected output:
Rank Member
1 image Dravid
2 image Richard Nixon
3 image GrahamBell
4 image Mark twains
Output's getting:
Rank Member
1 image Dravid
2 image RichardNixon
3 image GrahamBell
4 image Mark twains
img {margin-right:10px;};
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Rank</th>
<th scope="col">Member</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">1</th>
<td><img src="image"/>member</td>
</tr>
<tr>
<th scope="row">2</th>
<td><img src="image"/>anotherMember</td>
</tr>
<tr>
<th scope="row">3</th>
<td><img src="image"/>oneMoreMember</td>
</tr>
</tbody>
</table>
Please check your table markup, it doesn't seems to have any data in <tbody> . If you have to show the user image before the username place the <img/> inside the <td> tag just before the name of the member(in your case username). This will give you the alignment as per your need, no matter how long is the username provided that the size(mostly width) of all the images is same. I have included little CSS just to provide some space between all images and usernames. Also make sure this space remains constant for all images, if you wish to include it.
Your problem is that you are using the text-center class on each <tr>'s second <td> (to display the username). That's because your those are centered accordingly resulting in this bug:
In order to solve this you have to replace it with text-left like in this example. The same for the second <th>. In order to place your item more to the right, apply a padding-left, e.g., by adding Bootstrap's pl-5:
<table style="width: 100%; table-layout: fixed" class="table table-striped text-center">
<thead class='bg-dark' style='background-color: 3658DE'>
<tr>
<th><img src='https://via.placeholder.com/25'/> Rank</th>
<th class="text-left pl-5"><i class='fa fa-user mr-1' style='color: #F4B806'></i>Members</th>
</tr>
</thead>
<tbody>
<tr>
<td>
1
</td>
<td>
<div class='text-left pl-5'>
<img src='https://via.placeholder.com/150' alt='user dp' class='img-fluid rounded-circle' style='height: 30px; width: 30px;' />
<span class='mr-1 '>Dravid</span>
</div>
</td>
</tr>
<tr>
<td>
2
</td>
<td>
<div class='text-left pl-5'>
<img src='https://via.placeholder.com/150' alt='user dp' class='img-fluid rounded-circle' style='height: 30px; width: 30px;' />
<span class='mr-1 '>RichardNixon</span>
</div>
</td>
</tr>
<tr>
<td>
3
</td>
<td>
<div class='text-left pl-5'>
<img src='https://via.placeholder.com/150' alt='user dp' class='img-fluid rounded-circle' style='height: 30px; width: 30px;' />
<span class='mr-1 '>GrahamBell</span>
</div>
</td>
</tr>
</tbody>
</table>
You can find a running fiddle here, which produces the following table:
I've tried to look at a few web pages but none of them seem to be addressing the specific issue I'm having. I'm trying to make a web page and I'm trying to make a table aligned to the left side of the web page with while the rest in center aligned. However the items ligned in the center are pushed over to the right where the left aligned table is. How can I align something in the center without it being interefered with something aligned on the left side of the page?
Here is my code.
`<!doctype html>
<title> Webpage.</title>
<body>
<body background="Data/Back.jpg">
<table style="float: left" bgcolor="#9999FF" border="solid">
<tr>
<th><ul><h1>Directory.</h1></ul></th></tr>
<br>
<tr><td><li><a href="subpages/skills.html">Skills.</li></td></tr>
<tr><td><li><a href="subpages/experience.html">Experience.</li></td>
</tr>
<tr><td><li><a href="subpages/References">References.</li></td></tr>
<tr><td><li><a href="subpages/ContactInfo.html">Contact Info.</li>
</td></tr>
<tr><td><li><a href="subpages/Resume.html">Resume.</li></td></tr>
</table>
<center>
<table bgcolor="CCCCCC" border="3px solid black">
<tr>
<th><h1><b><u>Name/Header.</u></b></h1></th>
</tr>
</table>
<img src="Data/Me.jpg" width="25%">
<table bgcolor="#819FF7" width="50%" border="solid">
<tr>
<th>About me.</th>
</tr>
<tr>
<td>Subject
</td>
</tr>
</center>
<style type="text/css">
h1{
color: #0404B4
}
th{
color: #61380B
}
td{
color: #8A0829
}
</style>
</body>`
Simply remove float: left from the first table. Floating an element means that other elements will attempt to occupy any remaining width when that element is less than 100% of the width of the parent. Alternatively, clear the floats afterwards with clear: both.
Here's an example, cleanly formatted, and removing float: left.
h1 {
color: #0404B4;
}
th {
color: #61380B;
}
td {
color: #8A0829;
}
<body>
<table bgcolor="#9999FF" border="solid">
<tr>
<th>
<div style="margin-left: 2em">
<h1>Directory.</h1>
</div>
</th>
</tr>
<tr>
<td>
<ul>
<li>
Skills.
</li>
</ul>
</td>
</tr>
<tr>
<td>
<ul>
<li>
Experience.
</li>
</ul>
</td>
</tr>
<tr>
<td>
<ul>
<li>
References.
</li>
</ul>
</td>
</tr>
<tr>
<td>
<ul>
<li>
Contact Info.
</li>
</ul>
</td>
</tr>
<tr>
<td>
<ul>
<li>
Resume.
</li>
</ul>
</td>
</tr>
</table>
<center>
<table bgcolor="#CCCCCC" border="3px solid black">
<tr>
<th>
<h1><b><u>Name/Header.</u></b></h1>
</th>
</tr>
</table><img src="Data/Me.jpg" width="25%">
<table bgcolor="#819FF7" border="solid" width="50%">
<tr>
<th>About me.</th>
</tr>
<tr>
<td>Subject</td>
</tr>
</table>
</center>
</body>
Hope this helps! :)
I want #idTable and #userTable to be beside each other and the button below #idTable. I have tried display: inline-block; but it didn't help. Also, I have tried to put the button after the div#userTable but that would make the button go down more every time that table gets populated with more data. I want the button to remain still on the left side. While the #userTable and its info on the right side of the first table.
HTML:
<input type="date" />
<input type="date" />
<br style="clear:both" />
<table border="1" id="idTable">
<tr>
<th><b>#</b>
</th>
<th><b>ID</b>
</th>
</tr>
<tr>
<td>// #'s here</td>
<td>// ID's here</td>
</tr>
</table>
<br style="clear:both" />
<button>Update</button>
<div id="userTable">
<table border="1">
<tr>
<td><b>ID</b>
</td>
<td>Name</td>
</tr>
<tr>
<td colspan="2">
<table border="1" style="width:100%">
<tr>
<td><b>ID</b></td>
<td><b>Name</b></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
CSS:
#idTable{
display:inline-block;
}
#userTable{
display:inline-block;
}
JSFiddle Link
You can put #idTable and the button into another div (e.g. #wrapper) and set its float property to left.
HTML:
<div id='wrapper'>
<table border="1" id="idTable">
<tr>
<th><b>#</b>
</th>
<th><b>ID</b>
</th>
</tr>
<tr>
<td>// #'s here</td>
<td>// ID's here</td>
</tr>
</table>
<button>Update</button>
</div>
CSS:
#wrapper {
float: left;
}
See http://jsfiddle.net/82zv67d7/7
I am trying to finish up my website design but I am having trouble displaying some divs and aligning them.
This is what I am trying to achieve:
This is what I am getting:
index.php
style.css
jsFiddle: http://jsfiddle.net/wMvL5/
content (the central div that contains the 'Latest Projects' and 'Latest News' divs:
<div class="content">
<div class="projects">
<h1>Latest Projects</h1>
<div class="current_projects" align="center">
<div class="projects_gallery" align="center">
<table align="center">
<tr align="center">
<td>
<div class="project_desc_1">Project Description 1</div>
<div class="project_desc_2">Project Description 2</div>
<div class="project_desc_3">Project Description 3</div>
</td>
</tr>
<tr align="center">
<td>
<div class="slide"><img src="./images/blivori.png"/ id="project1"></div>
<div class="slide"><img src="./images/blivori.png"/ id="project2"></div>
<div class="slide"><img src="./images/blivori.png"/ id="project3"></div>
</td>
</tr>
<tr>
<td>
<ol class='project_selector' align="center">
<li></li>
<li></li>
<li></li>
</ol></td>
</tr>
<tr align="center">
<td>
<label id="description1">Description 1</label>
<label id="description2">Description 2</label>
<label id="description3">Description 3</label>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="empty_div_two"></div>
<div class="news">
<h1>Latest News</h1>
<div class="news_post" align="center">
<table align="center">
<tr>
<td style="width: 5%">►</td>
<td style="width: 95%"><label class="newspost1">News 1</label></td>
</tr>
<tr>
<td>►</td>
<td><label class="newspost2">News 1</label></td>
</tr>
<tr>
<td>►</td>
<td><label class="newspost3">News 2</label></td>
</tr>
<tr>
<td>►</td>
<td><label class="newspost4">News 3</label></td>
</tr>
<tr>
<td>►</td>
<td><label class="newspost5">News 4</label></td>
</tr>
<tr>
<td>►</td>
<td><label class="newspost6">News 5</label></td>
</tr>
<tr>
<td>►</td>
<td><label class="newspost7">News 6</label></td>
</tr>
<tr>
<td>►</td>
<td><label class="newspost8">News 7</label></td>
</tr>
<tr>
<td>►</td>
<td><label class="newspost9">News 8</label></td>
</tr>
<tr>
<td>►</td>
<td><label class="newspost10">News 9</label></td>
</tr>
<tr>
<td>►</td>
<td><label class="newspost10">News 10</label></td>
</tr>
</table>
</div>
</div>
Mostly I am having trouble of displaying two divs (empty_div_two) which is found between 'Latest Projects' and 'Latest News' (the seperator) and '.misc' which is being displayed at all. I am also trying to put the 'Latest News' at the top right of the div. Also, the border-radius for the header doesn't seem to work.
For border-radius on your header, Apply it to your .header-container instead of header.
.header-container {
border-top-left-radius: 30px;
border-top-right-radius: 30px;
}
And to fix other things, do the following: SEE THE DEMO
.empty_div_two {
background: #fff;
}
.projects {
float: left;
width: 60%;
}
.news {
width: 30%;
}
.current_projects // remove width: 49%;
.content // remove width: 1184px;