-1

How can I select a div when I hover a child h1 with css3 only.

I want the div to have a animated opacity:0, done with keyframes. I can do the keyframes part by myself. Just need help with the selection.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Erwin Ivanov
  • 103
  • 1
  • 6
  • the selection will depend on the html structure..so please provide your html code – Chiller Dec 07 '16 at 13:03
  • Your question could do with a little more clarity, for example, what is the `h1` a child of? Is the `div` in question a nested element of the `h1`? If not, how are you going to target it just using CSS? What have you already tried? And can you provide an example or reference of the desired end-result? – UncaughtTypeError Dec 07 '16 at 13:05
  • Possible duplicate of [Is there a CSS parent selector?](http://stackoverflow.com/questions/1014861/is-there-a-css-parent-selector) – roberrrt-s Dec 07 '16 at 13:32

2 Answers2

0

Ho ho .... the thing that you are asking is known as JS dom manipulation. For that a language is developed -- JavaScript. Any selection of HTML element and further manipulation is out of scope of CSS. It is only for styling and not for node manipulation dear!

Try out jQuery with .parentsUntil selector and your problem will be solved. Also, there is no such selector which would turn heel from end element to go to parent by CSS only. Though with SASS/LESS there may be some possibliites. But only CSS3 -- Nil, ie 0.

Deadpool
  • 7,811
  • 9
  • 44
  • 88
0

Does something simple like that work as you wish?

.wrapper{
  background:red; 
  transition: opacity 1s ease-in-out;
}
.header:hover {
  opacity: 0.5;
}
<div class="wrapper"><h1 class="header">Title</h1></div>
Theodore K.
  • 5,058
  • 4
  • 30
  • 46