Skip to content

Instantly share code, notes, and snippets.

@mateuszgachowski-snippets
Created February 7, 2014 15:45
Show Gist options
  • Save mateuszgachowski-snippets/8865195 to your computer and use it in GitHub Desktop.
Save mateuszgachowski-snippets/8865195 to your computer and use it in GitHub Desktop.
HTML: Hover element before hack
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="Test">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test table hover</title>
<link rel="stylesheet" href="css/style.css">
<link rel="author" href="humans.txt">
<style>
.table .parent td {
height: 38px;
background: transparent;
position: relative;
z-index: 4;
}
.table .child {
position: relative;
display: block;
}
.table .child:before {
content: ' ';
display: none;
position: absolute;
top: -42px;
height: 40px;
width: 100%;
background: #ccc;
z-index: 3;
}
.table .parent:hover td,
.table .parent:hover + .child {
background: #ccc;
}
.table .parent:hover + .child {
display: block;
}
.table .child:hover {
background: #ccc;
}
.table .child:hover:before {
display: block;
}
</style>
</head>
<body>
<table class="table">
<tr class="parent">
<td>Hello I am the fucking parent</td>
</tr>
<tr class="child">
<td>Testest</td>
</tr>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment