Here is a bona fide little CSS-Trick for ya’ll.
I knew I could make a “matrix” of squares with rollovers. Then I got to wondering if I could duplicate that matrix of rollovers elsewhere on the screen. I figured I could using the same technique as Remote Linking. Then I got to thinking I could make the rollover in the duplicate matrix different by using a different style of rollover.
The technique is pretty simple. The HTML for a single cell is just:
<a class="singlecell"><em>.</em></a>
The em element is what kicks over and constructs the second matrix.
The CSS is a little more complex, but it’s not bad. The em gets relative positioning and a right value of 200, so it just gets kicked to the right 200px. The regular anchor element goes red on hover, and the em moves background position. Each cell has display block, a width and height of 10px, and is floated left to create the matrix.
.singlecell {
width: 10px;
height: 10px;
display: block;
color: white;
background-color: white;
float: left;
}
.singlecell em {
position: relative;
width: 10px;
height: 10px;
right: 200px;
display: block;
background: yellow;
text-indent: -9999px;
}
.singlecell:hover {
background: red;
}
.singlecell:hover em {
background: blue;
}
This isn’t exactly super-useful as it is, but its a kinda neat trick that I could see being adapted into something more interesting.
See the Pen Matrix of Rollovers by Chris Coyier (@chriscoyier) on CodePen.
Now that is cool but how we could use it? Dunno but it looks nice :D
very cool…thats a lot of work though, but it doesnt work in IE, though its fine in firefox…
Fantastic trick Chris – I’m brainstorming for it’s use already…will let you know if I come up with something :P
Great work though.