I'm making a table and I got a few problems that I can't solve without help,namely:
I need all <td> to be the same height as it's respective <tr>. height:100% doesn't work for all <td> for some reason, however fixed height works.
<tbody> is smaller than <table> itself which leads to the gap on the right side.
I want all borders to be 1px, but some of them are more bold. How do I make them all uniform?
https://codepen.io/NoOneKnowsWhoIam/pen/rzweRV
* {
box-sizing: border-box;
}
.caption {
background: yellow;
padding: 5px;
}
table {
border-collapse: collapse;
border: 1px solid black;
width: 400px;
display: block;
margin: 0 auto;
background: grey;
}
.quarter-width {
width: 25%;
}
.half-width {
width: 50%;
}
.third-width {
width: 33.33333333333333%;
}
td {
padding: 5px;
width: 100%;
height: 100%;
border: 1px solid black;
display: inline-block;
}
.text-center {
text-align: center;
}
.text-right {
text-align: right;
}
<table>
<tbody>
<caption class="caption"><b>ST CLARE ZNNR5</b></caption>
<tr>
<td><b>11:39 01.07.2017</b></td>
</tr>
<tr>
<td class="half-width"><b>MMSI 235002514</b></td>
<td class="half-width text-right"><b>IMO 09236949</b></td>
</tr>
<tr>
<td>
<b>
Пассажирское судно, в пути<br>
86 м × 18 м × 2.5 м
</b>
</td>
</tr>
<tr>
<td class="half-width">
Координаты<br>
<b>50 47. 2000 N</b><br>
<b>001 06. 4000 W</b>
</td>
<td class="half-width text-right">
Время с момента получения отчета<br>
<b>9 с</b>
</td>
</tr>
<tr>
<td class="half-width">
Пункт назначения<br>
<b>Port Fish</b>
</td>
<td class=" fixim half-width text-right">
Расчетное время прибытия<br>
<b>
2017-07-01 17:15
<b>(UTC)</b>
</b>
</td>
</tr>
<tr class="text-center">
<td class="quarter-width">
COG<br>
<b>329°</b>
</td>
<td class="quarter-width">
COG<br>
<b>329°</b>
</td>
<td class="quarter-width">
HDG<br>
<b>323°</b>
</td>
<td class="quarter-width">
LOG<br>
<b>_</b>
</td>
</tr>
<tr>
<td><b>Спланированный маршрут</b></td>
</tr>
<tr>
<td class="third-width"><b>ПТ №1</b></td>
<td class="third-width">
Tдв<br>
<b>12:57:19</b>
</td>
<td class="third-width">
D<br>
<b>40.162 миль</b>
</td>
</tr>
<tr>
<td>Рассчитать маршрут</td>
</tr>
</tbody>
</table>
Delete display: inline-block; from the rule for td - this cancels their table-cell property, causing the problems you describe:
* {
box-sizing: border-box;
}
.caption {
background: yellow;
padding: 5px;
}
table {
border-collapse: collapse;
border: 1px solid black;
width: 400px;
display: block;
margin: 0 auto;
background: grey;
}
.quarter-width {
width: 25%;
}
.half-width {
width: 50%;
}
.third-width {
width: 33.33333333333333%;
}
td {
padding: 5px;
width: 100%;
height: 100%;
border: 1px solid black;
}
.text-center {
text-align: center;
}
.text-right {
text-align: right;
}
<table>
<tbody>
<caption class="caption"><b>ST CLARE ZNNR5</b></caption>
<tr>
<td><b>11:39 01.07.2017</b></td>
</tr>
<tr>
<td class="half-width"><b>MMSI 235002514</b></td>
<td class="half-width text-right"><b>IMO 09236949</b></td>
</tr>
<tr>
<td>
<b>
Пассажирское судно, в пути<br>
86 м × 18 м × 2.5 м
</b>
</td>
</tr>
<tr>
<td class="half-width">
Координаты<br>
<b>50 47. 2000 N</b><br>
<b>001 06. 4000 W</b>
</td>
<td class="half-width text-right">
Время с момента получения отчета<br>
<b>9 с</b>
</td>
</tr>
<tr>
<td class="half-width">
Пункт назначения<br>
<b>Port Fish</b>
</td>
<td class=" fixim half-width text-right">
Расчетное время прибытия<br>
<b>
2017-07-01 17:15
<b>(UTC)</b>
</b>
</td>
</tr>
<tr class="text-center">
<td class="quarter-width">
COG<br>
<b>329°</b>
</td>
<td class="quarter-width">
COG<br>
<b>329°</b>
</td>
<td class="quarter-width">
HDG<br>
<b>323°</b>
</td>
<td class="quarter-width">
LOG<br>
<b>_</b>
</td>
</tr>
<tr>
<td><b>Спланированный маршрут</b></td>
</tr>
<tr>
<td class="third-width"><b>ПТ №1</b></td>
<td class="third-width">
Tдв<br>
<b>12:57:19</b>
</td>
<td class="third-width">
D<br>
<b>40.162 миль</b>
</td>
</tr>
<tr>
<td>Рассчитать маршрут</td>
</tr>
</tbody>
</table>
Related
"I am working on creating an HTML template for an invoice and am having some difficulty placing the QR code image in the correct location. Specifically, I want the QR code image to appear directly under the invoice information table, but it is not appearing in the desired location.
table {
border-collapse: collapse;
font-family: Arial, sans-serif;
margin: 10px auto;
font-size: 14px;
color: #1e2b40;
}
td,
th {
border: 1px solid gray;
padding: 6px;
}
.center {
text-align: center;
}
.right {
text-align: right;
}
.bold {
font-weight: bold;
}
.contact-info {
font-family: Arial, sans-serif;
font-size: 12px;
float: right;
margin: 1px auto;
font-weight: normal;
}
.contact-info ul {
list-style-type: none;
}
.qr-code {
clear: both;
display: block;
width: 300px;
height: 300px;
margin: 0 auto;
}
.srs.logo {
width: 300px;
height: 150px;
margin: 10px auto;
}
.items-table {
float: left;
padding: 6px;
margin: 10px auto;
border-collapse: collapse;
width: 100%;
}
.items-table th,
.items-table td {
border: 1px solid gray;
padding: 6px;
<header>
<!-- header content goes here -->
<img src="https://drive.google.com/file/d/1mwNaPe8w4Bxn7mkXivmI2dqcwBg4_aog" alt="srs-logo" />
<div class="contact-info" style="list-style-type: none">
<ul>
<li>SARL RO SOLUTION</li>
<li>RC: RC:</li>
<li>NIF: NIF</li>
<li>AI: AI</li>
<li>Phone: Phone:</li>
<li>Email: info#company.com</li>
</ul>
</div>
</header>
<hr style="margin-top: 100px;">
<!-- rest of the page content goes here -->
<table style="float: left;">
<tr>
<td colspan="2" class="center bold">Customer Information</td>
<tr>
<tr>
<td>Customer Name:</td>
<td><<[Customer Name]>></td>
</tr>
<tr>
<td>Customer Address:</td>
<td><<[Customer Address]>></td>
</tr>
<tr>
<td>Customer NIF:</td>
<td><<[Customer NIF]>></td>
</tr>
<tr>
<td>Customer RC:</td>
<td><<[Customer RC]>></td>
</tr>
<tr>
<td>Customer AI:</td>
<td><<[Customer AI]>></td>
<tr>
<td>Telephone:</td>
<td><<[Company AI]>></td>
</tr>
</table>
<table style="float: right; margin: 0 auto">
<tr>
<td colspan="2" class="center bold">Invoice Information</td>
<tr>
<td>Invoice Date:</td>
<td><<[Invoice Date]>></td>
<tr>
<td>Invoice ID:</td>
<td><<[Invoice ID]>></td>
</tr>
</table>
<br style="clear: both;">
<img src="<<[Invoice Date]>>" alt="qr-code">
<br style="clear: both;">
<hr>
<table style="float: left;">
<tr>
<td rowspan="1" class="center bold">Related Sales</td>
<td colspan="" class="center bold">Invoice Information</td>
</table>
<br style="clear: both;">
<hr>
<table class="items-table">
<thead>
<tr>
<th>Item description</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<p class="startifend"><<Start:[invoice_key].[Related invoice_items]>></p>
<tr>
<td><<[description]>></td>
<td><<[quantity]>></td>
<td><<[unit_price]>></td>
<td><<[total_price]>></td>
</tr>
<p class="startifend"><<End>></p>
</tbody>
</table>
<br style="clear: both;">
<hr>
I'm going to presume you have a good reason for using tables over grid/flexbox.
A couple of issues to note. Firstly, be very care to always close your <tr> tags there were many unclosed tags through the code which I've corrected in the below snippet.
Secondly, the behaviour of the QR img tag was completely correct in your example and it was rendering where it should have been. In order to achieve the desired outcome, you want to put your Customer Information and Invoice Information tables inside a parent table.
In short:
<table>
<tr>
<td> <!-- Customer Information Table --> </td>
<td> <!-- Invoice Information Table --> </td>
</tr>
</table>
This will allow you to but the QR img directly underneath the Invoice Information Table inside the same <td> tag.
table {
border-collapse: collapse;
font-family: Arial, sans-serif;
margin: 10px auto;
font-size: 14px;
color: #1e2b40;
}
td,
th {
border: 1px solid gray;
padding: 6px;
}
.center {
text-align: center;
}
.right {
text-align: right;
}
.bold {
font-weight: bold;
}
.contact-info {
font-family: Arial, sans-serif;
font-size: 12px;
float: right;
margin: 1px auto;
font-weight: normal;
}
.contact-info ul {
list-style-type: none;
}
.qr-code {
clear: both;
display: block;
width: 300px;
height: 300px;
margin: 0 auto;
}
.srs.logo {
width: 300px;
height: 150px;
margin: 10px auto;
}
.items-table {
float: left;
padding: 6px;
margin: 10px auto;
border-collapse: collapse;
width: 100%;
}
.items-table th,
.items-table td {
border: 1px solid gray;
padding: 6px;
<header>
<!-- header content goes here -->
<img src="https://drive.google.com/file/d/1mwNaPe8w4Bxn7mkXivmI2dqcwBg4_aog" alt="srs-logo" />
<div class="contact-info" style="list-style-type: none">
<ul>
<li>SARL RO SOLUTION</li>
<li>RC: RC:</li>
<li>NIF: NIF</li>
<li>AI: AI</li>
<li>Phone: Phone:</li>
<li>Email: info#company.com</li>
</ul>
</div>
</header>
<hr style="margin-top: 100px;">
<!-- rest of the page content goes here -->
<table style="border:0; width:100%;">
<tr>
<td style="border:0; vertical-align:top">
<table style="float:left;margin:0">
<tr>
<td colspan="2" class="center bold">Customer Information</td>
</tr>
<tr>
<td>Customer Name:</td>
<td><<[Customer Name]>></td>
</tr>
<tr>
<td>Customer Address:</td>
<td><<[Customer Address]>></td>
</tr>
<tr>
<td>Customer NIF:</td>
<td><<[Customer NIF]>></td>
</tr>
<tr>
<td>Customer RC:</td>
<td><<[Customer RC]>></td>
</tr>
<tr>
<td>Customer AI:</td>
<td><<[Customer AI]>></td>
</tr>
<tr>
<td>Telephone:</td>
<td><<[Company AI]>></td>
</tr>
</table>
</td>
<td style="border:0; vertical-align:top;text-align:right;">
<table style="float:right;">
<tr>
<td colspan="2" class="center bold">Invoice Information</td>
</tr>
<tr>
<td>Invoice Date:</td>
<td><<[Invoice Date]>></td>
</tr>
<tr>
<td>Invoice ID:</td>
<td><<[Invoice ID]>></td>
</tr>
</table>
<br style="clear:both;">
<img src="<<[Invoice Date]>>" alt="qr-code">
</td>
</tr>
</table>
<br style="clear: both;">
<hr>
<table style="float: left;">
<tr>
<td rowspan="1" class="center bold">Related Sales</td>
<td colspan="" class="center bold">Invoice Information</td>
</tr>
</table>
<br style="clear: both;">
<hr>
<table class="items-table">
<thead>
<tr>
<th>Item description</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<p class="startifend"><<Start:[invoice_key].[Related invoice_items]>></p>
<tr>
<td><<[description]>></td>
<td><<[quantity]>></td>
<td><<[unit_price]>></td>
<td><<[total_price]>></td>
</tr>
<p class="startifend"><<End>></p>
</tbody>
</table>
<br style="clear: both;">
<hr>
This should do the trick, added a container to the tables and applied flex box. Remove the margin from the table selector, if you want the tables to go to the left and right edges.
<div style="display:flex;justify-content:space-between;">
<table>
<tr>
<td colspan="2" class="center bold">Customer Information</td>
<tr>
<tr>
<td>Customer Name:</td>
<td><<[Customer Name]>></td>
</tr>
<tr>
<td>Customer Address:</td>
<td><<[Customer Address]>></td>
</tr>
<tr>
<td>Customer NIF:</td>
<td><<[Customer NIF]>></td>
</tr>
<tr>
<td>Customer RC:</td>
<td><<[Customer RC]>></td>
</tr>
<tr>
<td>Customer AI:</td>
<td><<[Customer AI]>></td>
<tr>
<td>Telephone:</td>
<td><<[Company AI]>></td>
</tr>
</table>
<table>
<tr>
<td colspan="2" class="center bold">Invoice Information</td>
<tr>
<td>Invoice Date:</td>
<td><<[Invoice Date]>></td>
<tr>
<td>Invoice ID:</td>
<td><<[Invoice ID]>></td>
</tr>
</table>
</div>
<img style="float:right;" src="<<[Invoice Date]>>" alt="qr-code">
How can I make columns in two tables have the same width?
I tried applying the width property on the td element for each column and the property style = "table-layout: fixed; but as you can see, the boundaries of the columns do not match.
JSFiddle: https://jsfiddle.net/v2bxdygj/
Here is my sample which works to some extent:
table {
border: 1px solid grey;
border-collapse:collapse;
width: 100%;
table-layout:fixed;
}
td {
border: 1px solid grey;
padding-left: 5px;
padding-right: 5px;
white-space: nowrap;
}
td span {
white-space: nowrap;
}
.code {
width: 40px;
}
.name {
width: 548px;
}
.colspan {
width: 588px;
}
.col3, .col4, .col5 {
width: 10%;
}
<table>
<tr>
<td class="code"><button>Код</button></td>
<td class="name"><button>Название</button></td>
<td class="col3"> </td>
<td class="col4"> </td>
<td class="col5"> </td>
</tr>
<tr>
<td class="colspan" colspan="2"><input type="text"> <span>Фильтр по коду и названию...</span></td>
<td class="col3">Разрешено</td>
<td class="col4">Запрещено</td>
<td class="col5">Неопределено</td>
</tr>
</table>
<table>
<tr>
<td class="code">1</td>
<td class="name">Вход в систему</td>
<td class="col3"> </td>
<td class="col4"> </td>
<td class="col5"> </td>
</tr>
<tr>
<td>2</td>
<td>Редактирование, администрирование групп и пользователей</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>3</td>
<td>Создание или редактирование определения адресного элемента</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>4</td>
<td>Создание или редактирование записи адресного элемента</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
I am programming in css and html. i made a table but when the page width changes only one column changes width it instead of every. For styling reasons I used different tags for different td-elements. the table. the relevant code is probably the css part with the table-layout:fixed; line.
/* basic style*/
.c_container{
margin:0 auto;
width: 80%;
height: auto;
}
.c_week{
font-weight: bold;
background-color: rgba(255,0,0,0.2);
}
.c_td:hover{
background-color: #add8e6;
}
.c_November{
text-align: center;
background-color: #CDCDCD;
}
.c_weekdays{
color: black;
background-color: #D0F0C0;
}
.c_calendar, .c_th, .c_td, .c_week{
width: 100%;
table-layout: fixed;
text-align: center;
font-size: 20px;
border:3px solid #000;
border-collapse: collapse;
cursor: pointer;
}
.c_td{
text-align: left;
vertical-align: top;
font-size: 10px;
}
/* markere helg */
.c_weekend{
background-color: #FED8E1;
}
/* markerer datoer som ikke er i november */
.c_graydays{
background-color: #D3D3D3;
}
/* markere spesielle hendelser*/
.c_expedition, .c_talent, .cr_talent{
background-color: #FFFCBB;
}
/* hover*/
.c_expedition .c_expeditiontext {
visibility: hidden;
color: white;
background-color: black;
text-align: center;
position: absolute;
z-index: 2;
border-radius: 8px;
padding: 10px;
}
.c_expedition:hover .c_expeditiontext {
visibility: visible;
}
.c_talent .c_talenttext {
visibility: hidden;
color: white;
background-color: black;
text-align: center;
position: absolute;
z-index: 2;
border-radius: 8px;
padding: 10px;
}
.c_talent:hover .c_talenttext {
visibility: visible;
}
.cr_talent .cr_talenttext {
visibility: hidden;
color: white;
background-color: black;
text-align: center;
position: absolute;
z-index: 2;
border-radius: 8px;
padding: 10px;
}
.cr_talent:hover .cr_talenttext {
visibility: visible;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Calendar</title>
<link rel="stylesheet" href="calendar.css">
<script type="text/javascript" src="calendar.js" async></script>
</head>
<body>
<div class="c_container">
<div class="c_November" >
<h2 id="c_title">November 2020</h2>
</div>
<table id="c_calendar" >
<tr>
<th class="c_weekdays c_th">Week</th>
<th class="c_weekdays c_th">Mon</th>
<th class="c_weekdays c_th">Tue</th>
<th class="c_weekdays c_th">Wed</th>
<th class="c_weekdays c_th">Thu</th>
<th class="c_weekdays c_th">Fri</th>
<th class="c_weekdays c_th">Sat</th>
<th class="c_weekdays c_th">Sun</th>
</tr>
<tr>
<td class="c_week " >44</td>
<td class="c_graydays c_td" >26</td>
<td class="c_graydays c_td" >27</td>
<td class="c_graydays c_td" >28</td>
<td class="c_graydays c_td" >29</td>
<td class="c_graydays c_td" >30</td>
<td class="c_graydays c_weekend c_td" >31</td>
<td class="c_weekend c_td">1</td>
</tr>
<tr>
<td class="c_week " >45</td>
<td class="c_td">2</td>
<td class="c_td">3</td>
<td class="c_td">4</td>
<td class="c_td">5</td>
<td class="c_td">6</td>
<td class="c_weekend c_td">7</td>
<td class="c_weekend c_td">8</td>
</tr>
<tr>
<td class="c_week ">46</td>
<td class="c_td">9</td>
<td class="c_td">10</td>
<td class="c_td">11</td>
<td class="c_td">12</td>
<td class="c_td">13</td>
<td class="c_weekend c_td">14</td>
<td class="c_weekend c_td">15</td>
</tr>
<tr>
<td class="c_week" >47</td>
<td class="c_td">16</td>
<td class="c_td">17</td>
<td class="c_td">18</td>
<td class="c_expedition c_td">19
<span class="c_expeditiontext"> Thursday the 19th of November all pupils will have an expedition to damlia, our local dam. There we will learn more about insects and other wildlife near the dam. The trip will be from 08:00 to 15:00. Meet at the main entrance 07.45 and remember to pack a lunch!</span>
</td>
<td class="c_td">20</td>
<td class="c_weekend c_td">21</td>
<td class="c_weekend c_td">22</td>
</tr>
<tr>
<td class="c_week ">48</td>
<td class="c_talent c_td">23
<span class="c_talenttext"> 23rd of november is the time for the biyearly talentshow! The show will take place in auditorium A1 at 18.00 til 21.00.</span> </td>
<td class="cr_talent c_td">24
<span class="cr_talenttext"> This is a rerun of yesterdays talentshow, except this time parents are welcome as well! (at auditorium A1 18.00 - 21:00)</span>
</td>
<td class="c_td">25</td>
<td class="c_td">26</td>
<td class="c_td">27</td>
<td class="c_weekend c_td" >28</td>
<td class="c_weekend c_td">29</td>
</tr>
<tr>
<td class="c_week ">49</td>
<td class="c_td">30</td>
<td class="c_graydays c_td" >1</td>
<td class="c_graydays c_td" >2</td>
<td class="c_graydays c_td" >3</td>
<td class="c_graydays c_td" >4</td>
<td class="c_graydays c_weekend c_td" >5</td>
<td class="c_graydays c_weekend c_td" >6</td>
</tr>
</table>
</div>
</body>
</html>
This is text to post my question
This is text to post my question
This is text to post my question
This is text to post my question
This is text to post my question
This is text to post my questionThis is text to post my question
This is text to post my question
This is text to post my question
This is text to post my question
This is text to post my question
This is text to post my question
Apply width: 100% only to the table itself (#c_calendar ), not to the cells or other elements (i.e. erase it from the rule for .c_calendar, .c_th, .c_td, .c_week).
If you want the first column to be wider than the others, you can apply a min-width setting to it.
Edit: If you want all other cells to always have the same width, you can apply a min-width to .c_td, which I just added in my snippet below.
To force all cells to have the same width (if possible, depending on content), you can also simply apply min-width to td (and maybe also th).
/* basic style*/
.c_container{
margin:0 auto;
width: 80%;
height: auto;
}
.c_week{
font-weight: bold;
background-color: rgba(255,0,0,0.2);
}
.c_td {
min-width: 50px;
}
.c_td:hover{
background-color: #add8e6;
}
.c_November{
text-align: center;
background-color: #CDCDCD;
}
.c_weekdays{
color: black;
background-color: #D0F0C0;
}
#c_calendar {
width: 100%;
}
.c_calendar, .c_th, .c_td, .c_week{
table-layout: fixed;
text-align: center;
font-size: 20px;
border:3px solid #000;
border-collapse: collapse;
cursor: pointer;
}
.c_td{
text-align: left;
vertical-align: top;
font-size: 10px;
}
/* markere helg */
.c_weekend{
background-color: #FED8E1;
}
/* markerer datoer som ikke er i november */
.c_graydays{
background-color: #D3D3D3;
}
/* markere spesielle hendelser*/
.c_expedition, .c_talent, .cr_talent{
background-color: #FFFCBB;
}
/* hover*/
.c_expedition .c_expeditiontext {
visibility: hidden;
color: white;
background-color: black;
text-align: center;
position: absolute;
z-index: 2;
border-radius: 8px;
padding: 10px;
}
.c_expedition:hover .c_expeditiontext {
visibility: visible;
}
.c_talent .c_talenttext {
visibility: hidden;
color: white;
background-color: black;
text-align: center;
position: absolute;
z-index: 2;
border-radius: 8px;
padding: 10px;
}
.c_talent:hover .c_talenttext {
visibility: visible;
}
.cr_talent .cr_talenttext {
visibility: hidden;
color: white;
background-color: black;
text-align: center;
position: absolute;
z-index: 2;
border-radius: 8px;
padding: 10px;
}
.cr_talent:hover .cr_talenttext {
visibility: visible;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Calendar</title>
<link rel="stylesheet" href="calendar.css">
<script type="text/javascript" src="calendar.js" async></script>
</head>
<body>
<div class="c_container">
<div class="c_November" >
<h2 id="c_title">November 2020</h2>
</div>
<table id="c_calendar" >
<tr>
<th class="c_weekdays c_th">Week</th>
<th class="c_weekdays c_th">Mon</th>
<th class="c_weekdays c_th">Tue</th>
<th class="c_weekdays c_th">Wed</th>
<th class="c_weekdays c_th">Thu</th>
<th class="c_weekdays c_th">Fri</th>
<th class="c_weekdays c_th">Sat</th>
<th class="c_weekdays c_th">Sun</th>
</tr>
<tr>
<td class="c_week " >44</td>
<td class="c_graydays c_td" >26</td>
<td class="c_graydays c_td" >27</td>
<td class="c_graydays c_td" >28</td>
<td class="c_graydays c_td" >29</td>
<td class="c_graydays c_td" >30</td>
<td class="c_graydays c_weekend c_td" >31</td>
<td class="c_weekend c_td">1</td>
</tr>
<tr>
<td class="c_week " >45</td>
<td class="c_td">2</td>
<td class="c_td">3</td>
<td class="c_td">4</td>
<td class="c_td">5</td>
<td class="c_td">6</td>
<td class="c_weekend c_td">7</td>
<td class="c_weekend c_td">8</td>
</tr>
<tr>
<td class="c_week ">46</td>
<td class="c_td">9</td>
<td class="c_td">10</td>
<td class="c_td">11</td>
<td class="c_td">12</td>
<td class="c_td">13</td>
<td class="c_weekend c_td">14</td>
<td class="c_weekend c_td">15</td>
</tr>
<tr>
<td class="c_week" >47</td>
<td class="c_td">16</td>
<td class="c_td">17</td>
<td class="c_td">18</td>
<td class="c_expedition c_td">19
<span class="c_expeditiontext"> Thursday the 19th of November all pupils will have an expedition to damlia, our local dam. There we will learn more about insects and other wildlife near the dam. The trip will be from 08:00 to 15:00. Meet at the main entrance 07.45 and remember to pack a lunch!</span>
</td>
<td class="c_td">20</td>
<td class="c_weekend c_td">21</td>
<td class="c_weekend c_td">22</td>
</tr>
<tr>
<td class="c_week ">48</td>
<td class="c_talent c_td">23
<span class="c_talenttext"> 23rd of november is the time for the biyearly talentshow! The show will take place in auditorium A1 at 18.00 til 21.00.</span> </td>
<td class="cr_talent c_td">24
<span class="cr_talenttext"> This is a rerun of yesterdays talentshow, except this time parents are welcome as well! (at auditorium A1 18.00 - 21:00)</span>
</td>
<td class="c_td">25</td>
<td class="c_td">26</td>
<td class="c_td">27</td>
<td class="c_weekend c_td" >28</td>
<td class="c_weekend c_td">29</td>
</tr>
<tr>
<td class="c_week ">49</td>
<td class="c_td">30</td>
<td class="c_graydays c_td" >1</td>
<td class="c_graydays c_td" >2</td>
<td class="c_graydays c_td" >3</td>
<td class="c_graydays c_td" >4</td>
<td class="c_graydays c_weekend c_td" >5</td>
<td class="c_graydays c_weekend c_td" >6</td>
</tr>
</table>
</div>
</body>
</html>
I'm trying to make some kind of "menu", but my menu items have too large heights in IE. Tested it on chrome, firefox and safari and it's working fine. What's wrong with my code? Please help. I just want them to be "fixed" 2em in height, is it possible in ie? And I wonder, is it an error in my page or just an IE bug?
window.onload=init;
window.onpageshow=init;
function init()
{
var main=document.getElementById("mainview");
var str=String.fromCharCode(Math.round( Math.random()*(90-65))+65);
var chr;
for(var i=0;i<20000;i++)
{
chr=String.fromCharCode(Math.round(Math.random()*(122-97))+97);
if(chr!="<") str=str+chr;
if(Math.random()<0.02)
{ chr=". "+String.fromCharCode(Math.round(Math.random()*(90-65))+65);
}
if(Math.random()<0.2)
{ str+=" ";
}
str+=chr;
}
main.innerHTML=str;
}
table
{ width: 100%;
border-collapse: collapse;
border-spacing: 0px;
padding: 0;
background-color: #fff;
table-layout: fixed;
}
tr.first
{
background-color: #000;
height: 2em;
}
tr.space
{
height: 1em;
}
td.lmargin
{
width: 3em;
}
td.label
{
width: 10em;
height: 4em;
background-color: #c30425;
}
td.menu
{
padding-left: 2em;
vertical-align: middle;
height: 2em;
border-top: 1px solid #000;
border-bottom: 1px solid #000;
}
td.dummy
{
height: auto;
}
td#mainview
{
padding-left: 2em;
}
<table>
<tr class="first">
<td class="lmargin">
</td>
<td rowspan="2" class="label">
</td>
<td>
</td>
</tr>
<tr>
<td class="lmargin">
</td>
<td>
</td>
</tr>
<tr class="space">
<td class="lmargin">
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td class="lmargin">
</td>
<td class="menu">
Menu item 1
</td>
<td rowspan="6" id="mainview">
</td>
</tr>
<tr>
<td class="lmargin">
</td>
<td class="menu">
Menu item 2
</td>
</tr>
<tr>
<td class="lmargin">
</td>
<td class="menu">
Menu item 3
</td>
</tr>
<tr>
<td class="lmargin">
</td>
<td class="menu">
Menu item 4
</td>
</tr>
<tr>
<td class="lmargin">
</td>
<td class="menu">
Menu item 5
</td>
</tr>
<tr>
<td class="lmargin">
</td>
<td class="dummy">
</td>
</tr>
</table>
Update: found the reason
https://support.microsoft.com/en-us/kb/2312750
The ROWSPAN property is disabled in Internet Explorer 8 if a webpage contains a tag in a table cell
It seems IE does not allow right cell to be larger than the left cell. Open developer console on IE (press F12) change
<td id="mainview" rowspan="6">
to
<td id="mainview" rowspan="1">
and see the differences.
I would like to create rowspan on my sticky header but can't get it work.
JsFiddle: http://jsfiddle.net/x62v5ea8/1/
What i need is to connect first and second td in 'Header 1'
Can someone help me with this problem ?
HTML
<div class="my-wrapper">
<div class="my-scroller">
<table class="myTable">
<thead>
<tr>
<th class="my-sticky-col">Header 1</th>
<th class="my-sticky-col2">Header 2</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
<th>7</th>
<th>8</th>
<th>9</th>
<th>10</th>
<th>11</th>
<th>12</th>
<th>13</th>
<th>14</th>
<th>15</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="2" class="my-sticky-col">A</td>
<td class="my-sticky-col2"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="my-sticky-col"> </td>
<td class="my-sticky-col2"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="my-sticky-col">C</td>
<td class="my-sticky-col2"> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
</div>
</div>
CSS
body {
font-size: 1em;
}
.myTable {
border: none;
border-right: solid 1px #DDEFEF;
border-collapse: collapse;
border-spacing: 0;
font: normal 13px Arial, sans-serif;
}
.myTable thead th {
background-color: #EEE;
border: none;
color: #336B6B;
padding: 10px;
text-align: left;
text-shadow: 1px 1px 1px #fff;
white-space: nowrap;
}
.myTable tbody td {
color: #333;
padding: 10px;
text-shadow: 1px 1px 1px #fff;
white-space: nowrap;
}
.myTable tbody td, .myTable thead th {
border: 1px solid #ccc;
}
.my-wrapper {
position: relative;
}
.my-scroller {
margin-left: 283px;
overflow-x: scroll;
overflow-y: visible;
padding-bottom: 5px;
width: 300px;
}
.myTable .my-sticky-col {
left: 0;
position: absolute;
top: auto;
width: 120px;
}
.myTable .my-sticky-col2 {
border-right: solid 1px #000;
left: 142px;
position: absolute;
width: 120px;
}
Your code is actually working correctly. You are not seeing the rowspan working because the absolute positioning that is used for the sticky header. I updated your JS Fiddle with a few tweeks so you can see what is going on. http://jsfiddle.net/x62v5ea8/2/
You can see in the HTML I commented out the cell that will used by the rowspan and added a .test class with a height and background color so you can see that the cell is now fully expanding. Alternatively you can remove the position: absolute and you see the same results but your header wont be sticky anymore.