Image as background not working in Chrome and Safari - css

I am using jQuery.DataTables to display my data and everything seems to be working fine and i use DT_RowClass parameter in DataTables to assign class to everyrow in my DataTable.
Problem I am facing is, the class I am assigning to row has an background-image as property like:
.testClass { background: url("img/testClass.png") no-repeat 30px top; }
30px and top is used as I want image to appear bit right and at top. Now in Firefox and IE, I get 1 image in every row (as expected) but in Chrome and Safari, I get multiple images (1 in every column, 30px right in column and at top). Looks like, Chrome and Safari are applying class to every td whereas i have given it as tr level.
I have inspected CSS and their is no class at td level.
Anyone had this problem with these browser.
EDIT
My HTML looks like
<table>
<tr id="xyz" class="test">
<td>Test Columns1</td>
<td>Test Columns2</td>
<td>Test Columns2</td>
</tr>
</table>
Apologies, dont know how to format this properly

Related

Consistent positioning of <table> element across modern browsers

I have two <table> elements, and I want to arrange them vertically in a specific way by making the second <table> shift horizontally by a fixed amount of pixels.
For example:
<table id="table1" align="center">
...
</table>
<table id="table2" style="padding-left: 130px;">
...
</table>
However, I've found that in different browsers (e.g. Chrome vs Safari) the padding-left attribute causes slightly different results (i.e. while the second table appears fine in one browser, it is 2 or 3 pixels off the desired result in another browser). Is there any way to make this positioning consistent across all modern browsers? Preferably, a CSS-only solution is better.
Consider a CSS reset on padding and margin, browsers have default values for these, and the values are not the same across all browsers. The default values could be interfering your expected behavior.
* {
margin: 0;
padding: 0;
}
More on CSS reset: http://meyerweb.com/eric/tools/css/reset/

strange IE8 css issue

I have a header row which has this structure:
<th...
<a...
<span...
{text}
If you look at the attachement, you will notice that all the headers with this structure are aligned.
Well, when a specific header is clicked for "sorted" status, the structure will be like:
<th...
<a...
<span...
<table>
<tbody>
<tr>
<td>
{text}
</td>
<td>
<div> //with a background image
</td>
</tr>
</tbody>
</table>
Well, in IE8 this sorted column is no longer aligned (see the screenshot please).
I've tried a lot to put some css style (position:relative, etc) to the table inside the span to fix the alignment in IE8 but I failed..
Is here any css guru which can suggest a fix?
Please note that I can NOT change this structure (its some generated code from ICEfaces library) but I can apply css attributes (if I know where...).
Also, there is no css difference (some specific important style) to the sorted column applied. Just plain table inside that span.
Thanks.
Check the vertical-align property, maybe. Here, judging by the screencap, it seems to be in default mode, 'baseline'. (I'm not sure it will do much, though)
Try :
th.stuff {
vertical-align:top;
}
or :
th.stuff {
vertical-align:middle;
}
Also you could make all th slightly higher and gain somme padding to align the content. I think the problem, overall; commes from the select that appears in the th, inside the table.
You can use IE specific style sheets. They are known as conditional style sheets.
http://css-tricks.com/132-how-to-create-an-ie-only-stylesheet/
The idea of course would be to change the CSS for that element for IE only (because it does work already with other browsers).

CSS page-break-after within table in Safari?

I want each row of a table to be printed (media="print", not "screen") on separate page. So my HTML looks like this:
<table>
<tr style="page-break-after: always;">
<td><p>Page 1</p></td>
</tr>
<tr style="page-break-after: always;">
<td><p>Page 2</p></td>
</tr>
</table>
The page break works in Firefox and IE but not in Safari 4 nor Opera.
I tried adding the "page-break-after: always" to <td> and <p> but neither works. I can't seem to find a way to force a page break within a table in Safari and Opera.
Any idea on how to make it work in all Browsers?
Hate to only half answer your question, but...
In Opera, this will work with elements that are block elements (a table row is a table-row display type). As page-break-after applies only to those elements. I'm not sure how to make it work in Safari.
style="display:block;page-break-after: always;"

ASP.NET - Calendar control - Strike off dates with a custom strike

I want to strike off all the dates before today in a calendar control with an overlapping, red color x in ASP.NET. I can strikethru using the normal font strikethrough using the DayRender event. I can add an image but that sits adjacent to the date. I want the x (image) to overlap the date
Is this possible? If so, please help me how to go about it.
Thank you.
Use CSS,
Make the table cell position
relative
Make the image position
absolute, top & left: 0
Update:
The calendar control, like all ASP.NET control, outputs HTML. In this case it will output an HTML table, with a structure that looks something like this:
<table class="calendar_widget">
<tr>
<td>01</td>
<td>02</td>
<td>03</td>
<td>04</td>
<td>05</td>
<td>06</td>
<td>07</td>
</tr>
....etc
The <td>, or table-cell as it's known, will contain the date and image you're inserting. You can use CSS to apply specific styles to the cell and image so that they are rendered differently.
My guess is your calendar's HTML with an image will look something like this:
<td><img src="x.gif" />01</td>
You can use a CSS stylesheet to apply the following styles:
table.calendar_widget td {
position: relative;
}
table.calendar_widget td img {
position: absolute;
left: 0;
top: 0;
}
That's the basics of HTML - if this doesn't help I'd recommend tracking someone down familiar with front end development and getting their help.

CSS to make an empty cell's border appear?

What CSS should I use to make a cell's border appear even if the cell is empty?
IE 7 specifically.
If I recall, the cell dosn't exist in some IE's unless it's filled with something...
If you can put a (non-breaking space) to fill the void, that will usually work. Or do you require a pure CSS solution?
Apparently, IE8 shows the cells by default, and you have to hide it with empty-cells:hide But it doesn't work at all in IE7 (which hides by default).
Another way of making sure there is data in all cells:
$(document).ready(function() {
$("td:empty").html(" ");
});
If you set the border-collapse property to collapse, IE7 will show empty cells. It also collapses the borders though so this might not be 100% what you want
td {
border: 1px solid red;
}
table {
border-collapse: collapse;
}
<html> <head> <title>Border-collapse Test</title> <style type="text/css"> td {
border: 1px solid red;
}
table {
border-collapse: collapse;
}
<table>
<tr>
<td></td>
<td>test</td>
<td>test</td>
</tr>
<tr>
<td>test</td>
<td></td>
<td>test</td>
</tr>
<tr>
<td>test</td>
<td></td>
<td>test</td>
</tr>
<tr>
<td>test</td>
<td></td>
<td />
</tr>
</table>
The question asked for a CSS solution, but on the off-chance an HTML solution will do, here is one:
Try adding these two attributes to the table element: frame="box" rules="all"
like this:
<table border="1" cellspacing="0" frame="box" rules="all">
I just found the following. It's standards compliant but it doesn't work in IE. sigh.
empty-cells: show
I happened across this question and haven't seen any answers that really addressed the issue.
The problem results because IE7 does not see any internal content for the cell; in programming terms the cell is resulting as a null and like most things, you cannot border a null or perform any action on it. The browser needs an element/object that has a layout, in order to apply a border/layout.
Even empty <div></div> or <span></span> do not contain content, thus there is nothing to render, resulting in that null case again.
However, you can trick the browser into thinking the cell has content, by giving the empty div/span layout properties. The easiest way is to apply the CSS style zoom:1.
<table>
<tr><td>Foo</td>
<td><span style="zoom:1;"></span></td></tr>
</table>
This workaround is better than using a , since it doesn't unnecessarily mess up screen readers, and isn't misrepresenting the value of the cell. In newer browser you can use the empty-cell:<show|hide> alternative.
Note: in lieu of Tomalak's comment, it should be understood that hasLayout has nothing to do with null, it was merely a comparison of how the browser interacts and renders hasLayout similarly to how a database or programming language interacts with nulls. It is a strech, but I thought it might be easier to understand for those programmers turned web designers.
Ideally, you shouldn't have any empty cells in a table. Either you have a table of data, and there's no data in that specific cell (which you should indicate with "-", or "n/a/", or something equally appropriate, or - if you must - , as suggested), or you have a cell that needs to span a column or row, or you're trying to achieve some layout with a table that you should be using CSS for.
Can we have a bit more detail?
This question's old, but still a top result in Google, so I'll add what I've found:
Simply adding border-collapse: collapse to the table style fixed this problem for me in IE7 (and didn't affect the way they're displayed in FF, Chrome, etc).
Best to avoid the extraneous code of adding an or other spacing element when you can fix with CSS.
I guess this can't be done with CSS;
You need to put a in every empty cell for the border to show in IE...
empty-cell only fixed Firefox (YES I really did have this issue in Firefox) IE 7 & 8 were still problematic..
This worked for me in both Firefox 3.6.x, IE 7 & 8, Chrome, and Safari:
==============================
table {
*border-collapse: collapse;}
.sampleTD {
empty-cells: show;}
==============================
Had to use the * to make sure the table style was only applied to the IE browser.
Try this if you can't use non-breakable space:
var tn = document.createTextNode('\ ');
yourContainer.appendChild(ta);
I create a div style that has the same font color as the background of your cell and write anything (usually a "-" "n/a" or "empty") to give the cell content. It shows up if you highlight the page, but when viewed normally looks how you want.
I use a mix of html and css to create cross browser table grids:
html
<table cellspacing="1" style="background-color:#000;" border="0">
css
td{background-color:#fff;}
I haven't seen any issues with any browsers so far.
"IE" isn't a useful term in this context anymore now that IE8 is out.
IE7 always does "empty-cells:show" (or so I'm told ... Vista).
IE8 in any of its "Quirks" or "IE7 Standards" modes always does "empty-cells:hide".
IE8 in "Standards" mode defaults to "empty-cells:show" and supports the attribute via CSS.
As far as I know, every other browser has correctly supported this for several years (I know it was added in Firefox 2).
I'm taking this from another website but:
.sampletable {
border-collapse: collapse;}
.sampleTD {
empty-cells: show;}
Use for the CSS for the table and TD element respectively.

Resources