I have this code:
<tr>
<td width="40%" align="left" class="form_cell">
<span class="sub_header">Update or Delete</span><br />
Please select whether you would like us to update this contacts details, or delete them from the system.
</td>
<td width="60%" align="left" class="form_cell">
[class=form__parser func=updateDetails__updel(150.$update_or_delete$.true)]
</td>
</tr>
<tr>
<td width="100%" align="left" colspan="2" id="ammend_contact_details" style="display: none;">
<table border="0" cellspacing="0" cellpadding="0" width="100%" align="left">
<tr>
<td width="40%" align="left" class="form_cell">
<span class="sub_header">New Title</span><br />
Please enter the contacts new title, IE Mr, Mrs, Dr, Miss, Ms
</td>
<td width="60%" align="left" class="form_cell">
<input type="text" name="update_contact_title" class="input" size="48" maxlength="6" value="$update_contact_title$" />
</td>
</tr>
</table>
</td>
</tr>
The code which start with [class=form__parser...] creates a drop down list. If you click one of the options, the cell below it (ID ammend_contact_details) is displayed, otherwise its hidden.
The website address for this page is: http://www.westlandstc.com/index.php?plid=6#eyJwbGlkIjoiNTkiLCJjbGlkIjoiNDQ2Iiwic2NsaWQiOiJudWxsIiwiZHluYW0iOiJudWxsIiwiYXBwSWQiOiJudWxsIn0= and the element in question is at the very bottom of the page.
The problem is, the colspanattribute works fine in internet explorer (surprise surprise), however, in Chrome, all the content which is supposed to be spread over the 2 parent columns, only goes into the 1st column.
I have narrowed the bug down further, if I remove the style="display: none" attribute it works fine. Everytime I try to change either the display style or visibility style, Chrome places everything back into the first column.
In addition, I tried setting the background colour of the cell which spans 2 columns to red. In internet explorer, again this works as expected. In chrome, no background-color is displayed.
Any ideas how to fix this?
What are you setting the 'display' property to in order to show it? iirc you would need to use 'display:table-cell' (or similar - can't remember the exact value) in order for chrome to treat it as a table cell
style.display=''
works for me with chrome.
'display:table-cell'
does not
Rather than adding the CSS property display:inline to the <td>, which for some reason IE is happy with and Chrome is not, I would update your JavaScript to just remove the display:none style and let the browser's default display:table-cell take affect.
In the <select name="update_or_delete"> onchange method simply have:
if(this.value=='Update') {
document.getElementById('ammend_contact_details').style.display='';
} else {
document.getElementById('ammend_contact_details').style.display='none';
}
Chrome doesn't seem to respect colspan unless it has at least 1 row exactly matching number of columns in the table. I tried to make a grid with 2 items in 1st row and 3 items in 2nd row. For Firefox that's all you need:
td {
display: table-cell;
padding: 10px;
text-align: center;
background: #eee;
}
<table style="width: 100%">
<tr>
<td colspan="3" style="width: 50%">box 1.1</td>
<td colspan="3" style="width: 50%">box 1.2</td>
</tr>
<tr>
<td colspan="2" style="width: 33.33%">box 2.1</td>
<td colspan="2" style="width: 33.33%">box 2.2</td>
<td colspan="2" style="width: 33.33%">box 2.3</td>
</tr>
</table>
But it doesn't work on Chrome and Edge, even though all <td>s have default styling: display: table-cell. To fix it you need to add empty row with exact match for column count so it finally looks like this:
td {
display: table-cell;
padding: 10px;
text-align: center;
background: #eee;
}
<table style="width: 100%">
<tr>
<td colspan="3" style="width: 50%">box 1.1</td>
<td colspan="3" style="width: 50%">box 1.2</td>
</tr>
<tr>
<td colspan="2" style="width: 33.33%">box 2.1</td>
<td colspan="2" style="width: 33.33%">box 2.2</td>
<td colspan="2" style="width: 33.33%">box 2.3</td>
</tr>
<tr style="visibility: hidden">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
Related
I have spotted a strange issue with chrome when rendering table borders. I have four columns and I want the third column to have no borders. In Firefox it displays correctly, so that it looks like the first and second columns are a separate table from the fourth column, as you can see here:
However, in Chrome, the top border of the first columns extends right across all the other columns as you can see here:
This is what the html code is for this:
<tr style="border: none;">
<td style="width: 120px;">Surname</td>
<td style="width: 300px;">Bloggs</td>
<td style="border: none; width: 10px;"> </td>
<td rowspan="3" style="width: 100px;"><div class="studentimg" style="background-image:url('<%=strStudentPhoto%>');"></div></td>
</tr>
I know it is the first column that is cause the issue because I change the code to this:
<tr style="border: none;">
<td style="width: 120px;">Surname</td>
<td style="border-top: none; width: 300px;">Bloggs</td>
<td style="border: none; width: 10px;"> </td>
<td rowspan="3" style="border-top: none; width: 100px;"><div class="studentimg" style="background-image:url('<%=strStudentPhoto%>');"></div></td>
</tr>
and in Chrome it still shows as above, whereas in Firefox it now shows as only the first column have a top border, like this?
Anyone have any ideas how to fix this for Chrome?
Thanks
David
The following code (based on yours) does not show the problem you described in Chrome.
Note: I removed a lot of the inline styles, i removed the inline border from the trs, I applied rowspan="3" to the third cell in the first row and omitted the third cell in the following rows. For the rest of the settings see yourself in the snippet below:
table {
border-collapse: collapse;
}
td {
border: 1px solid #777;
}
<table>
<tr>
<td style="width: 120px;">Surname</td>
<td style="width: 300px;">Bloggs</td>
<td rowspan="3" style="border: none; width: 10px;"> </td>
<td rowspan="3" style="width: 100px;">
<div style="width:100px;height:100px;background:url(https://placehold.it/67x100/fc5) center center no-repeat;background-size:contain;"></div>
</td>
</tr>
<tr>
<td>Surname</td>
<td>Bloggs</td>
</tr>
<tr>
<td>Surname</td>
<td>Bloggs</td>
</tr>
</table>
I'm having trouble with a table's behaviour in Firefox. I want a table consisting of two columns in the ratio 3:1. The first column includes 3 images in a second table which should resize to fit into the column.
In Chrome the images resize to fit into the first column, which is correctly set to 75%. They do this whether I specify a max-width or do not give them any size attributes. However, in Firefox, the images do not resize and instead the cell expands to be greater than 75%, meaning that the contents of the second column becomes squashed.
The structure of the code looks like this:
<table border="0" cellpadding="10" cellspacing="10" style="width: 100%;">
<tbody>
<tr>
<td style="vertical-align:top;width:75%;">
<table cellpadding="2" cellspacing="0">
<tbody>
<tr>
<td>
<img src="image1.jpg" style="max-width:625px;" />
</td>
<td rowspan="2">
<img src="image2.jpg" style="max-width:240px;" />
</td>
</tr>
<tr>
<td>
<img src="image3.jpg" style="max-width:625px;" />
</td>
</tr>
</tbody>
</table>
</td>
<td>
Second column
</td>
</tr>
</tbody>
</table>
How can I adapt this code so that it works correctly in Firefox as well as in Chrome? I've read other related questions, but haven't been able to find a solution I can get to work.
P.S. Please no comments on how I shouldn't be using CSS like this. I have my reasons for not using a proper stylesheet while I'm playing around.
Unless I'm missing the boat, why don't you simply assign a relative width to the image? A value of 100% will ensure the image resizes in tandem with its parent table cell:
<table border="0" cellpadding="10" cellspacing="10" style="width: 100%;">
<tbody>
<tr>
<td style="vertical-align:top;width:75%;">
<img src="https://www.google.ca/images/srpr/logo11w.png" style="width:100%;" />
</td>
<td>
Second column
</td>
</tr>
</tbody>
</table>
ref: http://jsfiddle.net/j26Fm/
The trick here I would say is table-layout: fixed;. It does require some additional rules but table-layout is what brings it all together.
Check out: http://codepen.io/pstenstrm/pen/kLKxz
This is worked for me, in IE, FF and Chrome.
<table style="table-layout: fixed; width: 100%; border: 0; cellspacing: 0; cellpadding: 0;">
and
<tr valign="middle">
<td style="width: 25%;"></td>
<td style="width: 25%;"></td>
<td style="width: 25%;"></td>
<td style="width: 25%;"></td>
</tr>
I've got a table with two rows. The first row just has three cells. The second row has two cells, with the first cell containing another table that needs to fill the whole cell.
<table border="1" style="border-collapse:collapse;">
<tr>
<td style="WIDTH: 205px;">1</td> <!--This width doesn't apply in Chrome-->
<td style="width:100%;">2</td>
<td style="WIDTH: 5px;">3</td>
</tr>
<tr>
<td colspan="2">
<TABLE width="100%" border="1" style="border-collapse:collapse;table-layout: fixed;">
<TR>
<TD style="width:130px;">
A</TD>
<TD style="width:90px;">
B</TD>
<TD style="width:230px;">
C</TD>
</TR>
</TABLE>
</td>
<td>
D
</td>
</tr>
</table>
Simple enough, really....or so I thought.
It appears as I would expect in IE. But Chrome seems to not apply the width of the first cell correctly. It seems to be affected by the table in the cell below.
Why is this happening, and how can I get around this?
Two things you should do:
On the table element, use table-layout: fixed;
Insert columns and give them a width
(You could also assign width to table headers/cells of the first row)
Like this:
<table border="1" style="table-layout: fixed; width: 100%;">
<colgroup>
<col style="width: 205px;">
<col style="width: auto;">
<!-- Use "width: auto;" to apply the remaining (unused) space -->
<col style="width: 5px">
</colgroup>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<!-- Etc. -->
When using colspan on a cell, cell takes width of cell above instead of entire row when in Chrome. Works fine in IE. Even putting 100% width on cell doesn't change anything.
<table cellspacing="1px" cellpadding="0" border="0" id="shiftData">
<tr>
<td class="topRow">Employee</td>
<td class="topRow">Working For</td>
<td class="topRow">Shift</td>
<td class="topRow">Date</td>
<td class="topRow">Time</td>
</tr>
<tr>
<td>Audrey W</td>
<td>Justin B</td>
<td>Host</td>
<td>6/14/12</td>
<td>4:00pm</td>
</tr>
<tr><td colspan="5" align="right" class="buttonRow"><a class="approve" href="">Approve</a><a class="deny" href="">Deny</a></td></tr>
<tr>
<td>Justing B</td>
<td>Leigh Anne</td>
<td>Dishwasher</td>
<td>6/16/12</td>
<td>11:00am</td>
</tr>
</table>
I had a float: right; on the cell div that was apparently causing the issue in Chrome.
<table width="100%" border="0">
<table width="600" align="center" bgcolor="#ffffff">
<tr>
<td width="600" colspan="120">Banner Image</td>
</tr>
<tr>
<td width="400" colspan="80"></td>
<td width="10" colspan="2" bgcolor="yellow"></td>
<td width="190" colspan="38"></td>
</tr>
</table>
</table>
The alignment is messed up for the 2nd row. How can it be resolved?
Looks like there are a lot of issues here.
First off, this isn't valid html. The second table tag can't go where you have it. You need to do something like:
<table width="100%" border="0">
<tr><td>
<table width="600" align="center" bgcolor="#ffffff">
<tr>
<td width="600" colspan="3">Banner Image</td>
</tr>
<tr>
<td width="400"></td>
<td width="10" bgcolor="yellow"></td>
<td width="190"></td>
</tr>
</table>
</td></tr>
</table>
Which will probably solve your immediate problem. However, why on earth do you have 120 columns? That seems wrong by any standard.
Note I removed the colspan because it's use here seemed very inappropriate.
Also, you might ask yourself why you have the outer table tag anyway. It's not exactly doing anything for you that can't be done in a better manner.
Colspan is used to indicate how many COLumns a single column SPANs, not to indicate a pixel width, as it would appear that you are trying to do here.
Instead, use colspan to indicate how many columns a single column should span, and indicate the width of columns either using css styles or the "width" atttribute.
See this example:
http://jsfiddle.net/xixionia/yt3gf/
The second table should be better if you placed it inside a td on the first table. Then on the second table there's a lot of colspan.
<div>
<table>
<tbody>
<tr>
<td width="600" colspan="3">Banner Image</td>
</tr>
<tr>
<td width="400"></td>
<td width="10" bgcolor="yellow"></td>
<td width="190"></td>
</tr>
</tbody>
</table>
</div>
I do prefer to use div in place of table. But you still have a choice. As you can refer to the other post.
You would try:
<table width="100%" >
<table align="center" bgcolor="#ffffff" cellspacing="0" cellpadding="0" border="1">
<tr>
<td colspan="120">Banner Image</td>
</tr>
<tr>
<td style="width:400px;" colspan="80">a</td>
<td style="width:10px;" colspan="2" bgcolor="yellow">b</td>
<td style="width:190px;" colspan="38">c</td> </tr>
</table>
</table>
I add "border=1" and text in the cells in order to see the changes.
You got a table inside a table directly and thats not "valid".
Considering:
I want the banner to stretch across the table. The second row should be in proportion of width 400, 10 for the separator and 190
You should have:
<table style="width:100%; background-color: #fff;">
<tr>
<td colspan="3">Banner Image</td>
</tr>
<tr>
<td style="width: 66.6%"></td>
<td style="width: 1.6%; background-color: yellow;"></td>
<td style="width: 31.6%"></td>
</tr>
</table>
You are clearly trying to use tables to make layout wireframes. You should research more about CSS and html5.
This answer will probably fix your code but not the logic you are trying to apply.