Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Background-color overlapses with border on table cell in IE

I have a table with two simple table cells:

<table>
  <tr>
    <td>Test1</td>
  </tr>
  <tr>
    <td>Test2</td>
  </tr>
</table>

And I add the following CSS to the table cells:

td {
  border: 1px solid #000;
  background-color: #CCC;
}

For some reason when I view this in IE it shows the background on TOP of the border, if I uncheck the background in DOM explorer I can see the border is there.

I guess this has something to do with a parent element, but there are soooo many parent elements I can't paste all that code here.

Anyone has an idea what this might be?

like image 767
WtFudgE Avatar asked Jun 24 '15 15:06

WtFudgE


People also ask

What is the difference between border-style and border-color in CSS?

With the border-style property, you can set the appereance of the border. With the border-color property, you can set the color of the border.

How do I specify table borders in CSS?

To specify table borders in CSS, use the border property. The example below specifies a black border for <table>, <th>, and <td> elements: The table above might seem small in some cases.

How do I make a border invisible in CSS?

To avoid having double borders like in the example above, set the CSS border-collapse property to collapse. If you set a background color of each cell, and give the border a white color (the same as the document background), you get the impression of an invisible border:

How do I add a background color to an even table?

For zebra-striped tables, use the nth-child () selector and add a background-color to all even (or odd) table rows:


2 Answers

if you do not want to change the positioning, try

background-clip: padding-box;
like image 118
Niko3088 Avatar answered Nov 08 '22 20:11

Niko3088


As I expected, it was due to a position rule in CSS:

td {
    position: relative
}

No idea why this is, but removing that solved it.

Took me forever to narrow down tho, which is why i started this post in the first place, to save me time. but alright fixed now :)

like image 45
WtFudgE Avatar answered Nov 08 '22 19:11

WtFudgE