I need four boxes in the corners of a div. When falling onto any div, I want to display:block hidden div in the middle, sharing one border with the field that is currently hoarding.
Here is jsfiddle with my current solution
It works almost fine. However, there are some errors regarding the angular region. I am showing a block element with a background using :after . To achieve the effect of one border for two elements.
Problem:
Thus, in Chrome, hovering in this area, there is some strange alternating effect. Each 1px mouse movement hides and displays the contents of a div. You can see it here in action.
In newer Firefox, this looks fine, but there is another error in the jsfiddle created that you can check yourself.
I use a gray background only to better visualize the problem. Suppose we are now working for box 1. Tried some jQuery with hover and hover without success.
EDIT - Final Solution:
The most important thing is to set the pointer-events: none; element pointer-events: none; in after . Since I got a few votes here is more advanced jsfiddle code using SASS , and here using simple css:
CSS
.outer { width: 90%; height: 300px; position: relative; } .box-content { display: none; width: 80%; height: 80%; position: absolute; left: 10%; top: 13%; background: white; z-index: 1; } .box { width: 150px; height: 60px; position: absolute; border: 1px solid white; background: white; } .box:hover:after { content: ''; background-color: white; z-index: 2; position: absolute; width: 100%; height: 100%; left: 0; top: 0; } .box:hover p { z-index: 3; } .box p { position: absolute; top: 23px; left: 13px; color: black; padding: 0; margin: 0; } .box-one { top: 0; left: 0; } .box-one:hover { border: 1px solid blue; } .box-one:hover ~ .content-one { border: 1px solid blue; display: inline-block; pointer-events: none; } .box-two { top: 0; right: 0; } .box-two:hover { border: 1px solid red; } .box-two:hover ~ .content-two { border: 1px solid red; display: inline-block; pointer-events: none; } .box-three { bottom: 0; left: 0; } .box-three:hover { border: 1px solid yellow; } .box-three:hover ~ .content-three { border: 1px solid yellow; display: inline-block; pointer-events: none; } .box-four { bottom: 0; right: 0; } .box-four:hover { border: 1px solid green; } .box-four:hover ~ .content-four { border: 1px solid green; display: inline-block; pointer-events: none; }
HTML
<div class="outer"> <div class="box box-one"> <p>BOX NAME 1</p> </div> <div class="box box-two"> <p>BOX NAME 2</p> </div> <div class="box box-three"> <p>BOX NAME 3</p> </div> <div class="box box-four"> <p>BOX NAME 4</p> </div> <div class="box-content content-one"></div> <div class="box-content content-two"></div> <div class="box-content content-three"></div> <div class="box-content content-four"></div> </div>
css css-selectors css3
bdobry
source share