IE11 not recognizing z-index: -1 - css

I have a table that uses box-shadow when hovering on rows to display some styling. This was working fine until I discovered that in IE11 it not working.
The problem seems to be that using a z-index: -1 to avoid the td being above tr is not working as expected in IE11.
table td {
position:relative;
background-color: #EFEFEF;
z-index: -1;
}
I have created a fiddle that works in chrome but not in IE11: https://jsfiddle.net/pjz43a52/8/
So my questions are:
Is there any known issue with IE11 and z-index: -1? I found things related to z-index but not to this case specifically.
How can I solve this? I tried different things but none of them working without breaking the current behavior which is to have the box-shadow on top of the td.
Any ideas?

<table> is cancer...
Although I don't know WHY exactly such behaviors happen... But yeah - that's compatibility issues and we've to hack around it, so if we re-use the same code you wrote before, but instead of using a <table> we will use only <div>, the result will be the same, but it will work on IE11 - I tested it for you!
.container {
background-color: #fafafa;
z-index: 0;
}
.table {
position: relative;
width: 100px;
z-index: 1;
border-spacing: 0px;
border-bottom: 1px solid black;
}
.table .col {
position:relative;
background-color: #EFEFEF;
z-index: -1;
border-top: 1px solid black;
border-right: 1px solid black;
border-left: 1px solid black;
}
.table .row:hover {
position: relative;
box-shadow:
inset 5px 0 0 #dadce0,
inset -3px 0 0 #dadce0,
0 5px 2px 0 rgba(60,64,67,.3),
0 5px 3px 1px rgba(60,64,67,.15);
}
<div class="container">
<div class="table">
<div class="row">
<div class="col">Some Value</div>
</div>
<div class="row">
<div class="col">Some Value</div>
</div>
<div class="row">
<div class="col">Some Value</div>
</div>
</div>
</div>

Since you are setting the Z-Index property, when you using F12 developer tools (using IE 11) to select the elements, you can only select the table elements, instead of the tr, so, it will not trigger the hover action. Screenshot as below:
To solve this issue, you could add the following CSS style:
table tr{
display:block;
}
Then, when using F12 developer tools to select elements, we could select the table row. Thus, it will trigger the hover action.
The test sample as below:
<style type="text/css">
table {
position: relative;
z-index: 1;
border-spacing: 0px;
border-bottom: 1px solid black;
}
table td {
border-top: 1px solid black;
border-right: 1px solid black;
border-left: 1px solid black;
}
table tr{
display:block;
}
.container {
background-color: #fafafa;
z-index: 0;
}
table td {
position: relative;
background-color: #EFEFEF;
z-index: -1;
}
table tr:hover {
position: relative;
box-shadow: inset 5px 0 0 #dadce0, inset -3px 0 0 #dadce0, 0 5px 2px 0 rgba(60,64,67,.3), 0 5px 3px 1px rgba(60,64,67,.15);
}
</style>
<div class="container">
<table>
<tbody>
<tr>
<td>Some Value</td>
</tr>
<tr>
<td>Some Value</td>
</tr>
<tr>
<td>Some Value</td>
</tr>
</tbody>
</table>
</div>
The result:

Is there any known issue with IE11 and z-index: -1?
This is likely not related to z-index directly, but due to the fact that CSS 2.1 specified that,
The effect of position:relative on table-row-group, table-header-group, table-footer-group, table-row, table-column-group, table-column, table-cell, and table-caption elements is undefined. (https://www.w3.org/TR/CSS2/visuren.html#propdef-position)
This restriction has been lifted with the CSS 3 Positioning Module - but that doesn’t necessary mean, IE has kept up.
If you nest an additional element into your table cells and apply position, z-index and background to that, you should be able to get this basically working, https://jsfiddle.net/pjz43a52/10

Related

css gives weird artefacts when using element with :hover

I have css :hover element (table row) which behaves weirdly. On some machines it gives pixel artefacts which disappear by itself or when hover over and out again. Sometimes it's a whole line, sometimes just a fragment of it. On some machines including my own (same browser versions) I can't get the same behavior, which makes it very hard to test and fix.
Got the issues in Chrome (52.0.2743.116), Opera (39.0.2256.48), Firefox (48.0). Haven't managed to reproduce in Edge (25.10586) and IE (11.494).
Snippet (couldn't make it work, link below has a working example):
.table {
margin-bottom: 0;
}
.table > tbody > tr > td {
border: 0;
padding-top: 2px;
padding-bottom: 2px;
}
.table-wrapper {
width: 100%;
overflow-x: auto;
background-color: white;
padding: 1px;
height: auto;
max-height: 75vh;
border: 1px solid #616161;
/* Darkgray */
border-collapse: collapse;
}
.panel-body .table-wrapper {
border: 0;
}
/*Default draw color in table*/
.dfx-table {
color: black !important;
}
.row-disableMargin {
margin-left: -3px;
margin-right: 0;
}
.table-row {
height: 3em;
border-left: 3px solid transparent;
border-top: 1px solid #EEEEEE;
/* Lightgray */
border-collapse: collapse;
}
.table-row-link,
.row {
border-left-color: transparent;
border-left-style: solid;
border-left-width: 3px;
}
.table-row-link:hover {
cursor: pointer;
border-left: 3px solid #F44336 !important;
/* Red */
}
.table-header {
font-weight: normal !important;
color: #9E9E9E !important;
/* Gray */
border-right: 0px solid white !important;
border-bottom: 0px solid #EEEEEE;
/* Lightgray */
height: 3em;
vertical-align: middle;
}
.table-bordered > tbody > tr > th,
.table-bordered > tfoot > tr > th,
.table-bordered > thead > tr > th {
border-right: 0 !important;
border-left: 0 !important;
vertical-align: middle;
}
.table-header a {
font-weight: normal !important;
color: #9E9E9E !important;
/* Gray */
}
.table-header > th > a,
.dfx-table-header > a {
border-bottom: 2px solid transparent !important;
}
.table-header > th > a:hover,
.dfx-table-header > a:hover {
border-bottom: 2px solid #F44336 !important;
/* Red */
}
<div class="table-wrapper">
<table class="table table-bordered dfx-table">
<thead>
<tr class="table-header">
<th dfx-sort-col="Id">ID</th>
</tr>
</thead>
<tbody>
<tr class="table-row table-row-link">
<td>V001069</td>
</tr>
<tr class="table-row table-row-link">
<td>V001070</td>
</tr>
</tbody>
</table>
</div>
Screenshots of normal hover(1)
and with artefact(2) - vertical thin red lower line is the one which shouldn't be there:
Any ideas why this might happen?
Edit: made example on Snippet (doesn't work for some reason), also a copied it here: http://cssdeck.com/labs/full/uxjvf4fg
Well it's certainly a weird one, but then again, table rows have never played well with styles being applied to them in my experience.
What you can do instead, is just apply the border to the first cell within it like so:
.table-row-link:hover :first-child {
cursor: pointer;
border-left: 3px solid #F44336 !important; /* Red */
}
Here's your example from before, but working: http://cssdeck.com/labs/s56owpbt
As a general rule, I always apply "row styles" to the cells within them to get the effect I want. It tends to avoid weirdness like this.

border-left with 1px from the maintable

I want in a table in html a border left.
Here is the table
.weTable td{
border-color:#dcdcdc;
border-width:1px;
border-style:solid;
}
This is for the table cell and this has the table
border-left: 15px solid #548dd4;
My problem is I want a vertical line left and its not a straight line on this way.
Now:
What I want:
try this one?
table {
border-left: 15px solid #548dd4;
border-spacing: 0px;}
The problem is caused by the fact that borders meet at an angle so unless you remove the border from the top you cannot get straight 'joins'.
As an alternative, you could add extra padding-left to the cell and use an inset box-shadow like so.
table {
border-collapse: separate;
border-spacing: 5px;
margin: 1rem;
text-align: center;
}
table td {
width: 50px;
border-color: black;
border-width: 1px;
border-style: solid;
padding: 50px;
padding-left: 65px;
position: relative;
}
table td {
box-shadow: inset 15px 0 0 lightblue;
}
<table class="shadow">
<tr>
<td>aaa</td>
<td>aaa</td>
<td>aaa</td>
</tr>
</table>

css pure arrows inside td tag

I have a table. Inside that table some td have the class "arrow". For the td that have this class I would like to put an arrow (triangle) on the left border of that td. I would like to use only css to achieve that. Note that I wish the arrow to start below the top border and end above the bottom border. I tried to apply several "pure css arrows tutorials" I found on the internet but I do not manage to make it work on td. I hope I was clear and I hope someone might help. Thank you in advance for your replies. Cheers. Marc.
http://cssdesk.com/PzASe
My HTML :
<table>
<tr>
<td>td1</td>
<td class="arrow">td2</td>
<td class="arrow">td three</td>
</tr>
<tr>
<td>td4</td>
<td class="arrow">td five</td>
<td class="arrow">td6</td>
</tr>
</table>
My CSS:
table{
border-spacing: 0px;
border-collapse: collapse;
text-align:center;
vertical-align:middle;}
td{
padding:10px;
border:1px solid purple;}
.arrow:before {
content:'';
position: relative;
top: 0;
left: -10;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
border-right: 5px solid transparent;
border-left: 5px solid black;
}
What is your target audience with this? Most of the CSS techniques for drawing shapes like triangles involve things like insert new elements, and advanced CSS properties (read: don't work in IE), I would suggest biting the bullet and using an old-fashioned background image.
If you're doing it as a proof of concept, and you don't care what browser a visitor is using, have you looked at this tutorial on CSS tricks?
You would need to insert a <div> into those cells, and then apply styling like this:
.arrow div {
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid blue;
}
Try this css. Your td was center aligned which added that odd space before your arrow. (see it in action here css code
table{
border-spacing: 0px;
border-collapse: collapse;
text-align:center;
vertical-align:middle;}
td{
padding:10px;
border:1px solid purple;}
.arrow:before {
content:'';
position: relative;
top: 0;
left: -10;
border-top: 5px solid transparent;
border-bottom: 5px solid transparent;
border-right: 5px solid transparent;
border-left: 5px solid black;
}
.arrow {
text-align:left;
}

All borders are not displaying on table in ie7 compatible view

No sure why the borders are not displaying correctly. I tried:
/* ------ global ------ */
body {
margin: 0 auto;
padding:0 0;
font-family:Arial, Helvetica, sans-serif;
text-align:center;
color:#000;
}
/* ------ Content Wrapper ------ */
#wrapper {
margin: 0 auto;
width:760px;
text-align:left;
}
#content table {
font-size:.8em;
border-collapse:collapse;
text-align:left;
width:100%;
}
#content table td {
border:solid 1px black;
}
Do I need to list all the CSS border properties to get the borders on the whole table, like this:
border-top: 1px solid #000;
border-right: 1px solid #000;
border-bottom: 1px solid #000;
border-left: 1px solid #000;
or more ......
I haven't done this yet, but I have had to do this in the past with some tables to get the borders on all sides for lte IE7. It was just as a last resort since I didn't know what else to do.
Consider the following jsFiddle, which works correctly in IE7 by showing a 1 pixel solid black border on table cells.
I didn't change any of your code, but added a rule to include borders on table header cells table th as well as table data cells table td.
HTML:
<div id="content">
<table>
<tr>
<th scope="col">Column</th>
<th scope="col">Column</th>
</tr>
<tr>
<td>Cell</td>
<td>Cell</td>
</tr>
</table>
</div>
CSS:
#content table {
font-size: 0.8em;
border-collapse: collapse;
text-align: left;
width: 100%;
}
#content table th,
#content table td {
border: solid 1px black;
padding: 5px 10px;
}
If your table cells still aren't showing any borders, you might have one or more rules in your stylesheet that appear later — or have more CSS Specificity — that are overriding your styles.
Try using border-collapse:separate for IE7 like this:
#content table {
font-size:.8em;
border-collapse:collapse;
text-align:left;
width:100%;
*border-collapse:separate;
}
apply border-collapse: collapse to the table, it should fix it :)

Two color borders

Client wants two color borders for an embossed look. Can I do this on one element? I was hoping to avoid stacking two DOM elements with individual borders.
Yep: Use the outline property; it acts as a second border outside of your border. Beware, tho', it can interact in a wonky fashion with margins, paddings and drop-shadows. In some browsers you might have to use a browser-specific prefix as well; in order to make sure it picks up on it: -webkit-outline and the like (although WebKit in particular doesn't require this).
This can also be useful in the case where you want to jettison the outline for certain browsers (such as is the case if you want to combine the outline with a drop shadow; in WebKit the outline is inside of the shadow; in FireFox it is outside, so -moz-outline: 0 is useful to ensure that you don't get a gnarly line around your beautiful CSS drop shadow).
.someclass {
border: 1px solid blue;
outline: 1px solid darkblue;
}
Edit: Some people have remarked that outline doesn't jive well with IE < 8. While this is true; supporting IE < 8 really isn't something you should be doing.
This is very possible. It just takes a little CSS trickery!
div.border {
border: 1px solid #000;
position: relative;
}
div.border:before {
position: absolute;
display: block;
content: '';
border: 1px solid red;
height: 100%;
width: 100%;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
<div class="border">Hi I have two border colors<br />I am also Fluid</div>
Is that what you are looking for?
Another way is to use box-shadow:
#mybox {
box-shadow:
0 0 0 1px #CCC,
0 0 0 2px #888,
0 0 0 3px #444,
0 0 0 4px #000;
-moz-box-shadow:
0 0 0 1px #CCC,
0 0 0 2px #888,
0 0 0 3px #444,
0 0 0 4px #000;
-webkit-shadow:
0 0 0 1px #CCC,
0 0 0 2px #888,
0 0 0 3px #444,
0 0 0 4px #000;
}
<div id="mybox">ABC</div>
See example here.
Have you tried the different border styles available within the CSS spec? There's already two border styles that might accommodate your need:
border-style: ridge;
Or
border-style: groove;
Outline is good, but only when you want the border all around.
Lets say if you want to make it only on bottom or top you can use
<style>
#border-top {
border-top: 1px solid #ccc;
box-shadow: inset 0 1px 0 #fff;
}
</style>
<p id="border-top">This is my content</p>
And for bottom:
<style>
#border-bottom {
border-top: 1px solid #ccc;
box-shadow: 0 1px 0 #fff;
}
</style>
<p id="border-bottom">This is my content</p>
Hope that this helps.
Instead of using unsupported and problematic outline just use
background-color + padding for the inner border
normal border for the outer one.
Example:
HTML:
<img src="http://cdn3.thumbs.common.smcloud.net/common/8/6/s/863444wpPN.jpg/r-0,500-n-863444wpPN.jpg" alt="malkovich" />
CSS:
img {
padding: 1px;
background: yellow;
border:1px solid black;
}
TEST(JSFiddle):
img {
padding: 1px;
background: yellow;
border: 1px solid black;
}
<img src="http://cdn3.thumbs.common.smcloud.net/common/8/6/s/863444wpPN.jpg/r-0,500-n-863444wpPN.jpg" alt="malkovich" />
If by "embossing" you mean two borders around each other with two different colours, there is the outline property (outline-left, outline-right....) but it is poorly supported in the IE family (namely, IE6 and 7 don't support it at all). If you need two borders, a second wrapper element would indeed be best.
If you mean using two colours in the same border. Use e.g.
border-right: 1px white solid;
border-left: 1px black solid;
border-top: 1px black solid;
border-bottom: 1px white solid;
there are special border-styles for this as well (ridge, outset and inset) but they tend to vary across browsers in my experience.
Adding the following CSS properties to a border will achieve a double border of two distinct colors and identical widths for those who are interested.
Example:
Selector {
border: 10px red;
border-block-start-style: ridge;
border-inline-start-style: ridge;
border-inline-end-style: groove;
border-block-end-style: groove;
}
Not possible, but you should check to see if border-style values like inset, outset or some other, accomplished the effect you want.. (i doubt it though..)
CSS3 has the border-image properties, but i do not know about support from browsers yet (more info at http://www.css3.info/preview/border-image/)..
Simply write
style="border:medium double;"
for the html tag
You could use
<html>
<head>
<title>Two Colors</title>
<style type="text/css">
.two-colors {
background: none repeat scroll 0% 0% rgb(245, 245, 245); border-color: rgba(111,111,111,0.2) transparent;
padding: 4px; outline: 1px solid green;
}
</style>
<style type="text/css">
body {
padding-top: 20px;
padding-bottom: 40px;
background-color:yellow;
}
</style>
</head>
<body>
<a target="_blank" href="people.htm">
<img class="two-colors" src="people.jpg" alt="Klematis" width="213" height="120" />
</a>
</body>
</html>
This produces a nice effect.
<div style="border: 1px solid gray; padding: 1px">
<div style="border: 1px solid gray">
internal stuff
</div>
</div>

Resources