Non-Standard Free Width Height HTML Table - css

I'm trying to get an HTML markup that represents the following table layout:
I tried this but it's not working:
<table border="1">
<tr>
<td style="height: 800px">
1
</td>
<td style="width: 300px; height: 400px">
2
</td>
</tr>
<tr>
<td style="height: 200px">
<p>3</p>
</td>
<td style="height: 600px">
4
</td>
</tr>
</table>

This looks pretty close to the image you provided. It's a little tricky because it actually requires 3 rows, but once you get your head wrapped around rowspan, then it makes sense.
<table border="1">
<tr style="height: 200px;">
<td style="width: 400px;" rowspan="2">
1
</td>
<td style="width: 200px;">
2
</td>
</tr>
<tr style="height: 200px;">
<td rowspan="2">
4
</td>
</tr>
<tr style="height: 50px;">
<td>
<p>3</p>
</td>
</tr>
</table>

You just need to add another row and add rowspans:
<table border="1">
<tr>
<td style="width: 300px; height: 400px" rowspan="2">
1
</td>
<td style="width: 300px; height: 200px">
2
</td>
</tr>
<tr>
<td style="height: 200px" rowspan="2">
4
</td>
</tr>
<tr>
<td style="height: 100px">
3
</td>
</tr>
</table>
See jsfiddle: http://jsfiddle.net/mt009cha/
EDIT
Do you have to use tables? This seems more like a layout and divs might be more appropriate.
Html:
<div class="container">
<div class="left">
<div style="height: 498px">1</div>
<div style="height: 98px">3</div>
</div>
<div class="right">
<div style="height: 298px">2</div>
<div style="height: 298px">4</div>
</div>
</div>
CSS:
div {
border: 1px solid black;
}
.container {
width: 600px;
height: 600px;
}
.left {
width: 398px;
height: 100%;
float: left;
}
.right {
width: 198px;
height: 100%;
float: right;
}
See jsfiddle: http://jsfiddle.net/zynt5j7e/

FIDDL
If you must use tables:
<table class="tbl">
<tr>
<td>
<table>
<tr>
<td style="height: 800px">
<p>top left</p>
</td>
</tr>
<tr>
<td style="height: 200px">
<p>bottom left</p>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr>
<td style="height: 400px">
<p>top left</p>
</td>
</tr>
<tr>
<td style="height: 600px">
<p>bottom left</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
Some CSS:
.tbl, .tbl table { border-collapse: collapse; width:100%; }
.tbl td, .tbl table td{ border:1px solid black; padding:0; margin: 0; }

Related

how to align html5 video tag and image tag

I tried to align the html video tag and image in html table. But did not succeeded. Seems like video tag align more bottom instead of top.
Picture is attached how its look.
Css
.newsImage {
width: 354px;
height: 204px;
vertical-align: top;
text-align: left;
}
HTML:
<table cellpadding="0" cellspacing="0" class="auto-style1" align="center">
<tr>
<td colspan="5" style="height: 80px; margin-bottom: 20px;">
<h2>NYHETER</h2>
</td>
</tr>
<tr>
<td class="newsImage">
<span id="Content_lbImageNews1"><video width="354" height="240" controls="controls" preload="metadata"><source src="https://bokning.7a.se/Media/newsImages/11332241297A-v5.mp4#t=0.5" type="video/mp4">Your browser does not support the video tag.</video></span>
</td>
<td> </td>
<td class="newsImage">
<span id="Content_lbImageNews2"><img src="https://bokning.7a.se/Media/newsImages/1142145490news3.png" Height="204" Width="354"></span>
</td>
<td> </td>
<td class="newsImage">
<span id="Content_lbImageNews3"><img src="https://bokning.7a.se/Media/newsImages/279096911logga.jpg" Height="204" Width="354"></span>
</tr>
</table>
In your inline height value you set it to be 240 instead of 204 which matches your other elements:
<video width="354" height="240" controls="controls" preload="metadata">
Change that back and you should have to mess with any other code.
.newsImage {
min-width: 354px;
min-height: 204px;
vertical-align: top;
text-align: left;
}
<table cellpadding="0" cellspacing="0" class="auto-style1" align="center">
<tr>
<td colspan="5" style="height: 80px; margin-bottom: 20px;">
<h2>NYHETER</h2>
</td>
</tr>
<tr>
<td class="newsImage">
<span id="Content_lbImageNews1"><video width="354" height="204" controls="controls" preload="metadata"><source src="https://bokning.7a.se/Media/newsImages/11332241297A-v5.mp4#t=0.5" type="video/mp4">Your browser does not support the video tag.</video></span>
</td>
<td> </td>
<td class="newsImage">
<span id="Content_lbImageNews2"><img src="https://bokning.7a.se/Media/newsImages/1142145490news3.png" Height="204" Width="354"></span>
</td>
<td> </td>
<td class="newsImage">
<span id="Content_lbImageNews3"><img src="https://bokning.7a.se/Media/newsImages/279096911logga.jpg" Height="204" Width="354"></span>
</tr>
</table>
Have you try this to the css file
.newsImage {
vertical-align:top;
}
.newsImage {
vertical-align:top;
}
<html>
</html>
<body>
<table cellpadding="0" cellspacing="0" class="auto-style1" align="center">
<tr>
<td colspan="5" style="height: 80px; margin-bottom: 20px;">
<h2>NYHETER</h2>
</td>
</tr>
<tr>
<td class="newsImage">
<span id="Content_lbImageNews1"><div class="videoWrapper"><video width="100%" height="100%" controls="controls" preload="metadata"><source src="https://bokning.7a.se/Media/newsImages/11332241297A-v5.mp4#t=0.5" type="video/mp4">Your browser does not support the video tag.</video></div></span>
</td>
<td> </td>
<td class="newsImage">
<span id="Content_lbImageNews2"><img src="https://bokning.7a.se/Media/newsImages/1142145490news3.png" Height="204" Width="354"></span>
</td>
<td> </td>
<td class="newsImage">
<span id="Content_lbImageNews3"><img src="https://bokning.7a.se/Media/newsImages/279096911logga.jpg" Height="204" Width="354"></span>
</tr>
</table>
</body

CSS table row reorganisation

I want to move the last row of a table on top and shift all other rows one down. I tried what works for divs, but unfortunatelly it wont work for table rows.
HTML I used
.tablebodyclass tr {
top: auto;
bottom: 0px;
}
.tablebodyclass tr:last-of-type {
top: 0px;
bottom: auto;
}
<table class="table">
<tbody class="tablebodyclass">
<tr class="no-stripe hidden" style="display: table-row;">
<td class="align-right" colspan="3">bla bla1</td>
</tr>
<tr class="no-stripe hidden" style="display: table-row;">
<td class="align-right" colspan="3">bla bla2</td>
</tr>
<tr class="no-stripe hidden" style="display: table-row;">
<td class="align-right" colspan="3">bla bla3</td>
</tr>
<tr class="no-stripe hidden" style="display: table-row;">
<td><strong>THIS needs to be first</strong> </td>
<td class="align-right" colspan="2">xxxxxx
</tr>
</tbody>
</table>
https://jsfiddle.net/3ow0mrvy/1/
any hint on how to reorder table rows are highly appreicated
--endo
You can't reorder the rows with only CSS. jQuery or flexbox could help you out there. However, to mimic this with pure CSS, you could add a margin to the top row, and then set the last row to be position: absolute to make it appear on top:
.tablebodyclass tr {
top: auto;
bottom: 0px;
}
.tablebodyclass tr:last-of-type {
top: 0px;
bottom: auto;
}
tr:last-of-type {
position: absolute;
}
tr:first-of-type {
margin-top: 14px;
}
<table class="table table-condensed table-hover table-vertical-middle table-shop table-stack-phone">
<tbody class="tablebodyclass">
<tr class="no-stripe hidden" style="display: block;">
<td class="align-right" colspan="3">bla bla1</td>
</tr>
<tr class="no-stripe hidden" style="display: block;">
<td class="align-right" colspan="3">bla bla2</td>
</tr>
<tr class="no-stripe hidden" style="display: block;">
<td class="align-right" colspan="3">bla bla3</td>
</tr>
<tr class="no-stripe hidden" style="display: block;">
<td><strong>THIS needs to be first</strong> </td>
<td class="align-right" colspan="2">xxxxxx
</tr>
</tbody>
</table>
JSFiddle
You can use flex and order in order to achieve what you want.
tbody tr{
display: block;
border: 1px solid red;
}
<table class="table table-condensed table-hover table-vertical-middle table-shop table-stack-phone">
<tbody class="tablebodyclass" style="display: flex; flex-direction: column;">
<tr class="no-stripe hidden" style="order: 2;">
<td class="align-right" colspan="3">bla bla1</td>
</tr>
<tr class="no-stripe hidden" style="order: 3;">
<td class="align-right" colspan="3">bla bla2</td>
</tr>
<tr class="no-stripe hidden" style="order: 4;" >
<td class="align-right" colspan="3">bla bla3</td>
</tr>
<tr class="no-stripe hidden" style="order: 1;">
<td><strong>THIS needs to be first</strong> </td>
<td class="align-right" colspan="2">xxxxxx
</tr>
</tbody>
</table>
To learn more about how flex works you can look into this [great article].(https://css-tricks.com/snippets/css/a-guide-to-flexbox/)

Point a arrow next to a specific table row

How can I point the arrow the 'here' row?
I have try putting it in a td tag but makes the row bigger.
https://jsfiddle.net/6vx6033y/
<table cellpadding="4" cellspacing="0" border="0" align="center">
<tr>
<td style=" text-align: right;">test:</td>
<td style=" text-align: left;">-$15.00</td>
</tr>
<tr>
<td style=" text-align: right;">test:</td>
<td style=" text-align: left;">here</td>
</tr>
<tr>
<td style=" text-align: right;">test:</td>
<td style=" text-align: left;">$15.00 </td>
</tr>
<div class="arrow">↙</div>
</table>
you can also use a pseudo element: https://jsfiddle.net/6vx6033y/1/
tr.arrow:after {
content:' \2199';
position:absolute;
font-size:1.5em;
color:red
}
td {
border:solid;
}
<table cellpadding="4" cellspacing="0" border="0" align="center">
<tr>
<td style=" text-align: right;">test</td>
<td style=" text-align: left;">-$15.00</td>
</tr>
<tr>
<td style=" text-align: right;">test:</td>
<td style=" text-align: left;">$0.00</td>
</tr>
<tr class="arrow">
<td style=" text-align: right;">test:</td>
<td style=" text-align: left;">$15.00 </td>
</tr>
<tr>
<td style=" text-align: right;">tset:</td>
<td style="text-align: left;">$0.00</td>
</tr>
</table>
<td style=" text-align: left;">$15.00 <span class="arrow">&#8601</span></td>
https://jsfiddle.net/eceen7z4/
you can play with nth-child properties, like that:
.arrow2 TR:nth-child(2) TD:nth-child(2):after {
color: red;
content: "↙";
}
<table class="arrow2">
<tr>
<td style=" text-align: right;">test:</td>
<td style=" text-align: left;">-$15.00</td>
</tr>
<tr>
<td style=" text-align: right;">test:</td>
<td style=" text-align: left;">here</td>
</tr>
<tr>
<td style=" text-align: right;">test:</td>
<td style=" text-align: left;">$15.00 </td>
</tr>
</table>

How to place a div on right side of cascading tables - CSS

I have 3 tables, cascading one after the other. I have a div, that I want to place on right side of these tables. The height of div may vary according to text inside. Currently the div is displayed below tables, like the image below;
<table class="class1" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell1</td>
<td class="cell2">Cell2</td>
</tr>
<tr>
<td class="cell1">Cell3</td>
<td class="cell2">Cell4</td>
</tr>
</table>
<table class="class2" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell5</td>
<td class="cell2">Cell6</td>
</tr>
<tr>
<td class="cell1">Cell7</td>
<td class="cell2">Cell8</td>
</tr>
</table>
<table class="class3" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell9</td>
<td class="cell2">Cell10</td>
</tr>
<tr>
<td class="cell1">Cell11</td>
<td class="cell2">Cell12</td>
</tr>
</table>
<div class="mydiv">mydiv</div>
But I want to place the div next to tables, so that it can extend downwards.
Here is the working fiddle http://jsfiddle.net/ZHVuf/1/
You should add a container around you table like this :
Html
<div id="container">
<!-- Your table -->
</div>
And make him float left, like your div #myDiv
Css
#container {
float:left;
}
see updated fiddle.
On this second updated fiddle, I added a wrapper with a clearfix !
insertusernamehere commented that you could use overflow:hidden instead of the clearfix, see here for a new working way to do this with less code.
Apply float:left; to all the table and add clear:both; to second and third table.
now you already has float:left; for div just add position:relative;top:0; and see.
OR
create two divs and add tables in one with left floating and you already have second div.
<div class="tableContainerDiv" style="float:left;">
<table><tr><td></td></tr></table>
<table><tr><td></td></tr></table>
<table><tr><td></td></tr></table>
</div>
<div class="yourDiv" style="float:left;"></div>
html
<div class="cl">
<div style="float: left">
your tables
</div>
<div class="mydiv" style="float: left">mydiv</div>
</div>
css
.cl:after{ content: " "; display: block; height: 0px; clear: both; visibility: hidden;}
.cl {display: inline-block;}
/* Hides from IE-mac \\*/
* html .cl {height: 1%;}
.cl {display: block;}
/* End hide from IE-mac */
move tables inside another div , float to left;
HTML
<div class="table-wrap">
<table class="class1" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell1</td>
<td class="cell2">Cell2</td>
</tr>
<tr>
<td class="cell1">Cell3</td>
<td class="cell2">Cell4</td>
</tr>
</table>
<table class="class2" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell5</td>
<td class="cell2">Cell6</td>
</tr>
<tr>
<td class="cell1">Cell7</td>
<td class="cell2">Cell8</td>
</tr>
</table>
<table class="class3" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell9</td>
<td class="cell2">Cell10</td>
</tr>
<tr>
<td class="cell1">Cell11</td>
<td class="cell2">Cell12</td>
</tr>
</table>
</div>
<div class="mydiv">mydiv</div>
CSS
.class1{
width: 100px;
height: 100px;
background: orange;
}
.class2{
width: 100px;
height: 100px;
background: green;
}
.class3{
width: 100px;
height: 100px;
background: gray;
}
.mydiv{
width: 200px;
background: blue;
float: left
}
.table-wrap{float:left;}
<table>
<tr><td>
<table class="class1" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell1</td>
<td class="cell2">Cell2</td>
</tr>
<tr>
<td class="cell1">Cell3</td>
<td class="cell2">Cell4</td>
</tr>
</table>enter code here
<table class="class2" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell5</td>
<td class="cell2">Cell6</td>
</tr>
<tr>
<td class="cell1">Cell7</td>
<td class="cell2">Cell8</td>
</tr>
</table>
<table class="class3" cellpadding="0" cellspacing="0" style="margin-top: 0px;">
<tr>
<td class="cell1">Cell9</td>
<td class="cell2">Cell10</td>
</tr>
<tr>
<td class="cell1">Cell11</td>
<td class="cell2">Cell12</td>
</tr>
</table>
</td>
<td>
<div class="mydiv">mydiv</div>
</td>
</tr>
</table>

“vertical-align: middle” on table cells does not align to the middle with AlphaImageLoader in IE6

I'm trying to align some text on table cells with a PNG Transparent background, I uses the filter:progid:DXImageTransform.Microsoft.AlphaImageLoader() to fix this in IE6. But the text does not align to the middle with the style filter:
CSS:
.fh {
font-family:SimSun;
font-size:12px;
overflow:hidden;
padding:0 2px 2px;
text-align:left;
vertical-align:middle;
}
HTML:
<table width="200" border="1" cellpadding="2" class="x-table">
<tr>
<th scope="col"> </th>
</tr>
<tr style="height: 77px;">
<td class="fh" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='./shadow-trans.png')"> ABCDEFG</td>
</tr>
</table>
Screenshot:
"vertical_align_ie6" http://filer.blogbus.com/4216262/resource_4216262_1279530625v.png
Try shifting the height to the TD or the TABLE.
I find that this problem can be fixed by insert a div with a table in it to the origin td:
HTML:
<table cellspacing="0" cellpadding="0" class="x-table" style="position: absolute; width: 289px; left: 0px;">
<colgroup>
<col style="width: 72px;"/>
<col style="width: 72px;"/>
<col style="width: 72px;"/>
<col style="width: 72px;"/>
</colgroup>
<tbody>
<tr style="height: 77px;">
<td class="brw1 brss bbw1 bbss blw1 blss btw1 btss" style="border-color: rgb(153, 204, 255); filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='./shadow-trans.png', sizingMethod=crop);background-repeat: no-repeat;" id="A1-0" colspan="4">
<div class="fx" style="height: 76px;">
<table>
<tbody>
<tr>
<td class="fh bw" style="height: 76px; width: 288px;">ABCDEFG</td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
</tbody>
</table>

Resources