I am trying to construct an html table with 6 rows. The first row has one line of text which is heading. The second row has 3 columns (set as three td elements). Third row has three values in 3 columns (set as three td elements). 4th row has 3 images in 3 columns (again set as three td elements). This works correctly so far. Now I want to add a fifth row which is a line of text that spans the entire div and has a dotted underline. When I add this element it just draws the the dotted border to 1/3rd of the div only. If I set the width to 100%, the elements above it are dragged to the right of the screen. What am I doing wrong? Here is my complete HTML snippet:
<div id="ToySummary" style="border:solid; border-width:4px; border-color:gray; padding:4px; margin:10px">
<span style="font-family:Calibri; font-size:large; color:midnightblue; text-align:right"><b>FINAL RESULTS SUMMARY</b></span>
<table style="width:100%">
<tr>
<td style="width:33%; font-size:large"><i>Result</i></td>
<td style="width:33%; font-size:large"><i>Lucky Toy</i></td>
<td style="width:33%; font-size:large"><i>Lucky Peoples</i> </td>
</tr>
<tr>
<td style="width:33%; font-size:large">{{overall_result}}</td>
<td style="width:33%; font-size:large">{{lucky}}</td>
<td style="width:33%; font-size:large">{{lucky_peoples}}</td>
</tr>
<tr>
<td><img src={{some_png}} style="width:50px;height:50px;"></td>
<td><img src={{some_other_png}} style="width:50px;height:50px;"></td>
<td><img src={{another_png}} style="width:50px;height:50px;"></td>
</tr>
<tr>
<td style=" border-bottom-style:dotted; border-bottom-color: black; border-bottom-width: 2px;"><b><em>{{animal_test_note}}</em></b></td>
</tr>
<tr>
<td>{{toy_score_note}}</td>
</tr>
</table>
</div>
You're trying to make the last two tr's span all the columns? Try this
<tr>
<td colspan="3" style=" border-bottom-style:dotted; border-bottom-color: black; border-bottom-width: 2px;"><b><em>{{animal_test_note}}</em></b></td>
</tr>
<tr>
<td colspan="3">{{toy_score_note}}</td>
</tr>
Use colspan attribute inside to span ur dotted border across all columns.
{{animal_test_note}}
<td colspan="3" style=" border-bottom-style:dotted; border-bottom-color: black; border-bottom-width: 2px;"><b><em>{{animal_test_note}}</em></b></td>
this will fix it.
When I understand you right, you try to align a dotted bottom border to your fifth td cell? And every try goes wrong and does not cover the whole bottom line?
I would recommend using CSS classes and ids instead of writing the style part directly into the td tags.
It's messy coding! No offense!
And for your approach:
HTML part:
<td id="dotted">
CSS part:
#dotted {
border-bottom: dotted #000000; /* or any colour you prefer! */
width:100%;
}
By the way: using % and then px in your td tags could cause your problem stick to one.
that should fix it
Related
My goal is to style a button (or icon/image/etc.) in a table cell so that it fills the entire cell edge to edge.
I've created the following minimal example showing 3 rows. The first td in each row is colored Red, Green, or Blue for clarity and contains a div set to 100% width and height and a black background. The second td contains some content (could be anything) and has various height-related styles applied.
<table style="color:white">
<tbody>
<tr>
<td style="padding: 0; background:red">
<div style="height:100%; width:100%; background:black;">T1</div>
</td>
<td style="padding: 0; background:black;">padding:0</td>
</tr>
<tr>
<td style="padding: 0; background:green;">
<div style="height:100%; width:100%; background:black;">T2</div>
</td>
<td style="padding:10px; background:black;">padding:10px</td>
</tr>
<tr>
<td style="padding: 0; background:blue;">
<div style="height:100%; width:100%; background:black;">T3</div>
</td>
<td style="height:100px; background:black;">height:100px</td>
</tr>
</tbody>
</table>
You can see that because of the second td's height, the first td in the second and third rows are being resized without resizing their content. And the first row, with the 0px padding on the second cell, is working as intended with regards to the first cell, but requiring other cells to not be taller than my button is extremely limiting.
What is the correct way to implement this sort of cell-filling behavior? Preferably no-JS.
I have a set width table container, it will contain 3 text elements separated by single characters (>).
These text elements may contain text that cannot be fit in the container on a single line along with the rest, and must be wrapped.
The issue is when the text wraps, the cell will contain extra white space on the right hand side that then forces the other elements to wrap, where normally, without the white space, the succeeding elements would each fit on a single line.
Here is the desired behavior:
Where the first text element cannot fit on a single line and must wrap.
But any of the other text elements may also not fit on a single line and must wrap, leaving no extra white space.
Using a basic table layout:
<table class="table">
<tbody>
<tr>
<td>Membership Clubs and Organizations</td>
<td>></td>
<td>Books Wholesaler</td>
<td>></td>
<td>Music Management</td>
</tr>
</tbody>
</table>
.table {
width:450px;
border:1px solid black;
}
Here there is extra whitespace, causing the succeeding elements to also wrap.
After a lot of research, the closest i have come is by setting width:0.1% for the text elements.
Unfortunately this results in the separating characters having their own extra white space, which i have not been able to remove, i have been unable to reduce their width to fit their contents.
<table class="table">
<tbody>
<tr>
<td class="text">Membership Clubs and Organizations</td>
<td class="separator">></td>
<td class="text">Books Wholesaler</td>
<td class="separator">></td>
<td class="text">Music Management</td>
</tr>
</tbody>
</table>
.text {
width:0.1%;
}
.table {
width:450px;
border:1px solid black;
}
I settled on using tables because it got me closer to what i need, but i am open to use any format, the only requirement is that it be in pure css, and not use any javascript.
.text {
width:0.1%;
}
.table {
width:450px;
border:1px solid black;
}
<table class="table">
<tbody>
<tr>
<td class="text">Membership Clubs and Organizations</td>
<td class="separator">></td>
<td class="text">Books Wholesaler</td>
<td class="separator">></td>
<td class="text">Music Management</td>
</tr>
</tbody>
</table>
The width of the table is forcing the white-space to be there, no matter what. table-cells have extra space, so the words wrap when necessary, or the cells have no extra space, so the words wrap on every word.
I think the only option for zero whitespace is
td { word-break: break-all; }
.table {
width:450px;
border:1px solid black;
}
td {
word-break: break-all;
}
<table class="table">
<tbody>
<tr>
<td class="text">Membership Clubs and Organizations</td>
<td class="separator">></td>
<td class="text">Books Wholesaler</td>
<td class="separator">></td>
<td class="text">Music Management</td>
</tr>
</tbody>
</table>
just remove
.text {
width:0.1%;
}
I’m trying to have padding within my table row and have a bottom border for my row. So I have:
.subscription-row {
background-color: cyan;
min-height: 30px;
border-color: transparent;
border-style: solid;
border-width: 22px 16px 42px 20px;
border-bottom: 1px solid #C7CDD1;
}
on this HTML
<table id="subscriptions-table">
<thead>
<tr>
<th>Subscription</th>
<th>Download</th>
</tr>
</thead>
<tbody>
<tr class="even subscription-row header">
<td class="ig-header-title ellipsis">
<img src="/assets/s-icon-0d60471f901d65172728d3df0e793b2ee4493a529c1a1dca73409fdae56ad362.png" alt="S icon">
<a class="name ellipsis" target="_blank" href="/scenarios/18">My Scenario</a>
</td>
<td align="center"><img src="/assets/zip_icon-c2a0694959db12a0939d264d4283478c1f59a4b118df839d7020aca929a1df61.png" alt="Zip icon"></td>
</tr>
</tbody>
</table>
but the bottom border is not showing up the desired number of pixels away from the padding — https://jsfiddle.net/z13jdLk5/ . How can I force my solid border on the bottom of my row only while ensuring the appropriate amount of padding that I specified?
You can achieve padding by targeting the td inside of the subscription-row, and adding some padding to it.
.subscription-row td {
padding-bottom:10px;
}
Do note that if you use your current subscription-row class for your subsequent row styling, it will look as if only the bottom-most row will have the transparent row color you expected it to have. That is because the top of the row border has a transparent border styling which overwrites the previous row's bottom border styling.
Look here to understand more about your current problem >> Add border-bottom to table row <tr>
Can I make two line of a table not align, one tr is left, another is right, using position:relative or position:absolute and margin? But it also align.
How can I make two tr not align?
I want this:
What I want this is:
I have a html:
<table>
<tr colspan="2"><td>top</td><tr>
<tr><td>left 1 2 3</td><td>right</td></tr>
</table>
I want hide the 'left 1 2 3' slowly as a animate, then the width of 'right' becomes 100%
but the effect I need is when left td hide, the whole td move left, first text 'left' disappear, then 1, then 2,3, then the whole td hide.
I have tried this:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"> </script>
<style>
body{margin:0px}
</style>
<script>
function hid() {
$("#d1").animate({ "margin-left": "-102px" });
}
</script>
<table id="d1" cellpadding="0" cellspacing="0">
<tr >
<td style="position: relative; width: 100px; height:100px;border: 1px solid #0050D0;background: #96E555; cursor: pointer">
123
</td>
<td>
abc
</td>
</tr>
</table>
<input type="button" onClick="hid()">
This looks like what I want, but there is only one tr and it is move the whole table but not the tr.
You mean like this JSFiddle?
<table style='width:100%;'>
<tr>
<td style='text-align:right;'>RIGHT</td>
</tr>
<tr>
<td style='text-align:left;'>LEFT</td>
</tr>
</table>
Alternatively, the best way to do this is with two floated elements, as in this fiddle
<div style='border:1px solid black;width:100%;height:44px;'>
<div style='float:right;width:80px;border:1px solid black;height:20px;'></div>
<div style='clear:both;'></div>
<div style='float:left;width:80px;border:1px solid black;height:20px;'></div>
</div>
I want to shift a text label down by about 6px I am attaching the style:
.price-label{
font-family:Arial, Helvetica, sans-serif;
font-size:small;
position:relative;
bottom:-6px;
vertical-align:bottom;
}
The HTML is:
<table border="0" cellspacing="1" cellpadding="0">
<tr>
<td height="45" colspan="2" align="center"><p><span class="text">Name</span><span class="name-label"></span></p></td>
</tr>
<tr>
<td> </td>
<td class="price-label">54.67</td>
</tr>
<tr>
<td width="28" bgcolor="#CCCCCC"> </td>
<td height="45"> </td>
</tr>
<tr>
<td width="28" bgcolor="#CC3300"> </td>
<td height="112"> </td>
</tr>
<tr>
<td width="28" bgcolor="#CCCCCC"> </td>
<td height="22"> </td>
</tr>
</table>
Visually I want the 54.67 label to appear horizontally parallel - to the gap where the grey cell (top one) and red cell (second from top) meet. As the number represents that point in the bar to the left.
So if some other technqiue is better, please let me know, maybe I should be using DIVs would that give me more control?
If you want to shift it down, you need to shift it a positive 6px, not a negative 6px, and set the top property, not bottom
position: relative;
top: 6px;
If I'm reading this correctly, then you're trying to straddle the border between two table cells which won't work. You'll need to consolidate the first two cells in the right column and then rowspan="2" the new cell with the number in it. Then top or bottom vertically align the text in the cell and add some padding-top until it's aligned properly.
Label is an inline element, margin/padding would only work when you make it a block (inline-block, block or float). Try this:
.price-label {
padding:6px 0 0;
display: inline-block;
display: -moz-inline-box;
-moz-box-orient: vertical;
vertical-align: top;
zoom: 1;
*display: inline; }
You might be better off using:
.price-label { margin-top: 6px; }
It's difficult to know more without some context of what else is around that table cell though.
Use padding-top:6px; instead of positioning, which can get very messy with relation to sibling elements etc.. and has other-side effects.