The best solution is to put a div inside the cell with the height:
<td style="padding-left:5px;">
<div style="height: 50px; overflow:hidden;">
...
</div>
</td>
BTW, what is the span for? If you only need it for styling, you can style the cell directly instead.
Answer from RoToRa on Stack OverflowThe best solution is to put a div inside the cell with the height:
<td style="padding-left:5px;">
<div style="height: 50px; overflow:hidden;">
...
</div>
</td>
BTW, what is the span for? If you only need it for styling, you can style the cell directly instead.
The CSS property you are looking for is line-height. You simply have to put it in the <td>, not in the contained <span>
<td style="padding-left:5px; line-height: 50px; overflow: hidden">
</td>
TD HEIGHT not working - HTML & CSS - SitePoint Forums | Web Development & Design Community
html - How to force a TD to be a certain height with CSS? - Stack Overflow
Making div fill td cell using height:100%
object - HTML 'td' width and height - Stack Overflow
This has nothing to do with the td really, but with the nature of position: relative. A relative element's space stays reserved in the document flow.
Get rid of the relative, and use position: absolute on the first image instead.
Edit: I just saw your edit. Hmmm. Thinking.
Two workaround ideas come to mind:
Slap a
overflow: hiddenon thetdIf that doesn't work in all browsers or isn't valid (I'm not 100% sure right now) Put the two images into a
<div height='100px;'>and put aoverflow: hiddenon that.
Declaring
<td style="height: 100px; width:100px; overflow:hidden"> ...
should help you.
The width attribute of <td> is deprecated in HTML 5.
Use CSS. e.g.
<td style="width:100px">
in detail, like this:
<table >
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td style="width:70%">January</td>
<td style="width:30%">$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
Following width worked well in HTML5: -
<table >
<tr>
<th style="min-width:120px">Month</th>
<th style="min-width:60px">Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
Please note that
- TD tag is without CSS style.
I want the link to fill the entire containing cell, including vertically.
I have basically this:
<table> <tr> <td style="padding:0px; border:1px solid green;"><a href="https://google.com" style="display:block; margin:0px; height:100%; border:1px solid red;">Text</a></td> <td>Multi-Line<br />Text</td> </tr> </table>
If I put an explicit height ( height:100px; )on the containing cell then the internal element fills that height. Otherwise I get a gap.
Fiddle: https://jsfiddle.net/3c91Lkpz/
Edit: None of the suggestions quite worked right, so I convinced them to accept a different tack.
Edit 2: Following up for future people. I did find the following.
<style type="text/css">
td.biglink {
position: relative;
background-color: #ccc;
}
td.biglink:hover {
background-color: #eee;
}
td.biglink a::after {
content: '';
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
z-index: 0;
}
</style>
<table>
<tr>
<td class="biglink"><a href="http://www.google.com/">Cell 1<br>second line</a></td>
<td>Cell 2 no link<br><br><br><br></td>
<td class="biglink"><a href="http://www.google.com/">Cell 3</a></td>
</tr>
</table>The background color change is the cell background, otherwise the ::after background covers the text. You can do a semi-transparent hover if you don't want the cell to do it. The benefit is reducing the need of a class on the cell. The problem is that it still overlays the text.
<style type="text/css">
td {
position: relative;
}
td a::after {
content: '';
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
z-index: 0;
}
td a:hover::after {
background: rgba(170,234,204,0.5);
}
</style>
<table>
<tr>
<td><a href="http://www.google.com/">Cell 1<br>second line</a></td>
<td>Cell 2 No Link<br><br><br><br></td>
<td><a href="http://www.google.com/">Cell 3</a></td>
</tr>
</table>I am using an accounting software called Manager and you can create custom invoice themese within the program. The HTML coding uses Tables.
{% for field in fields %}
{{ field.label }}
{{ field.text }}
{% endfor %}
I am trying to get the field.label and field.text to have a maximum row height so I only have three labels vertically, with the last two labels and text next to it vertically. This way the invoice shows this:
Invoice Date Quote number
13/05/2019 1447
Due Date PO Number
31/05/2019 aaa
Invoice Number
abc
Currently the Quote Number and PO Number shows Underneath Invoice Number which pushes the table with the prices and goods further down.
I have tried max-height, height in different places and different px amounts but I can’t get this to work. Can anyone advise what I need to do. Thanks
Based on the code sample provided, you could wrap the entire FOR block inside another div, and set a max height on the outer div.
Another option would be to layout the data with Label in the left column and Field Value in the right column, thereby reducing your overall row count.
Additionally, unless this is a reduced version of the extant code you have an extra tag before the main one.
One additional thought - have you tried re-designing the page template to not rely on tables at all? By default tables will size themselves to the content rather than forcing the content to fit.