Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hover over container div is highlighting nested divs individually

Tags:

hover

I am placing a "hover" feature on class .one (.one :hover) to change the background-color to grey. I am expecting it to highlight both divs (.two, .three) any time I hover over the container .one div.

However, what it does is hover over the two nested divs (.two, .three) individually. Can someone please explain why this is so and what I have to do to make it highlight the entire div .one creating one single solid grey div?

Below is the CSS I used.

.one {
  width: 200px;
  display: inline-block;
}

.two {
  background-color: rgba(0, 51, 102, 1);
  width: 50px;
  height: 100px;
  float: left;
}

.three {
  background-color: rgba(0, 204, 204, 1);
  width: 150px;
  height: 100px;
  float: right;
}

.one :hover {
  background-color: rgba(153, 153, 153, 1);
}
<div class="one">
  <div class="two">
  </div>
  <div class="three">
  </div>
</div>
like image 557
Biglu315 Avatar asked Dec 01 '12 17:12

Biglu315


1 Answers

I think this CSS will help you:

.one:hover .two, .one:hover .three {
background-color: rgba(153,153,153,1);}
like image 148
anders Avatar answered Sep 28 '22 08:09

anders