html5 - CSS before and float on different elements work together -


i want :hover picture , showing :before on other element (h2) how can this?

if have both elements laid out siblings, can show them using sibling selector +:

img:hover + h2:before {display: block; width: 100%; height: 2px; background: #f00; content: ' ';}
<img src="http://lorempixel.com/400/200/" />  <h2>image</h2>


the above solution works if elements adjacent or somehow related, css cannot use parent selector (which possible in css 4 specification). can achieved using jquery:

$("img").mouseover(function () {   $("h2:before").css("display", "block"); }); 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -