You're not gonna be able to pull this off with only CSS. That's because there's no previous sibling selector in CSS.
So given this markup:
<div class="container">
<div id="box1" class="card">
<h1>one</h1>
<p>some text here</p>
</div>
<div id="box2" class="card">
<h1>two</h1>
<p>some text here</p></div>
<div id="box3" class="card">
<h1>three</h1>
<p>some text here</p></div>
</div>
You could select #box2
and #box3
when hovering #box1
with a selector like this:
div[id^="box"]:hover ~ div[id^="box"] {
//blurry stuff
}
But what happens when you hover #box2
or #box3
? You can't change the boxes before the one you hover.
We could try to think backwards and make things blurry by default and then do a simple :hover
selector to unblur the one you're hovering. That way you end up with the ones you're not hovering blurred, but it's not what you want because the boxes aren't normal-looking when not hovering.
Here's a simple example of an approach that'd work using jQuery's .not(). You could use it to toggle a class to do the blurring instead of putting the CSS in the function, if you wanted.
$(function(){
var boxes = $('div[id^="box"]');
$(boxes).on('mouseenter', function(){
$(boxes).not($(this)).css('background-color', 'red');
}).on('mouseleave', function(){
$(boxes).css('background-color', 'initial');
});;
});
.container {
width: 100%;
margin: 0 auto;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
}
.card {
border: solid black 1px;
padding: 20px;
-webkit-box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);
}
body {
margin: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div id="box1" class="card">
<h1>one</h1>
<p>some text here</p>
</div>
<div id="box2" class="card">
<h1>two</h1>
<p>some text here</p></div>
<div id="box3" class="card">
<h1>three</h1>
<p>some text here</p></div>
</div>
Final note: make sure to fix your header tags. For headers two and three, you have an <h1>
opening tag but an </h2>
closing tag.