Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS issue on iPad with table border

I have a CSS problem when the html page is rendered on iPad. Everything works good in other browsers. The problem is that I get a small space between the cells in my tables as you can see in the picture: http://oi53.tinypic.com/2vl0as9.jpg

If I zoom in the page maximum on the line between the cells, it dissappears.. So it must be some kind of bug when the page is rendered. Can I go around this in some way? This is my table and CSS:

<table class="smallTable" cellpadding=0 cellspacing=0>
    <tr>
        <td class="td1"></td>
        <td class="td2"></td>
    </tr>
    <tr>
        <td class="td1"></td>
        <td class="td2"></td>
    </tr>
</table>

CSS:

.smallTable 
{
    margin: 20px auto 40px auto;
    border-spacing: 0;
}

.smallTable td
{
    margin: 0;
}

.smallTable td.td1 
{
    background: url(../images/table1.png);
}

.smallTable td.td2 
{
    background: url(../images/table2.png);
}
like image 741
Martin Avatar asked Oct 08 '10 11:10

Martin


People also ask

Why is my table border not showing up CSS?

CSS Border Not Showing If you've set the shorthand border property in CSS and the border is not showing, the most likely issue is that you did not define the border style. While the border-width and border-color property values can be omitted, the border-style property must be defined.

Why is the CSS border collapse property used in tables?

The border-collapse CSS property sets whether cells inside a <table> have shared or separate borders.

How do I enable table borders?

To create table border in HTML, the border attribute was used. But the introduction of HTML5, deprecated the border tag. Create table border using the CSS property border. Set table border as well as border for <th> and <td>.


2 Answers

I just bashed my head against this bug for half a day while trying to make an HTML formatted email.

iPad's have a bug (gasp!) when viewing tables at a non 1:1 scale. This is especially apparent if your table's TD tags have a dark background and the TABLE's parent has a light color. Rowspans and colspans amplify the problem.

I initially thought the problem was that iPad was introducing a border.
The real problem is that the coders at Apple didn't decide if they were going to uniformly round fractions of a pixel up, or down while scaling.

Hence, some TD tags appear to have a border when not at 100% scale. When in reality it is just the light background showing through.

The solution is to wrap the table into another table that has the same dark background.

Welcome to 1998 web-design. I hear mp3.com is all the rage. Gonna buy me some mail-order dog treats from pets.com.

Thanks iPad.

like image 165
mrbinky3000 Avatar answered Oct 01 '22 02:10

mrbinky3000


I was able to fix it putting this meta tag in the html head when an iDevice (iPod, iPad, iPhone) is detected in the request.

<meta content='width=device-width; initial-scale=1.0;' name='viewport' />

Hope it helps.

like image 41
Zheileman Avatar answered Oct 01 '22 02:10

Zheileman