Page 1 of 1

This is where we finally use the selector

Posted: Sun Dec 22, 2024 9:39 am
by Nihan009
Explanation
First line: We set the bio dropdown wrapper to have relative positioning. This makes it easier to absolutely position the bio dropdown box closer to the original wrapper.
Second line: This makes the bio dropdown box invisible by default. It's only supposed to appear when you hover over something, remember?
Note: If you're not a fan of display: none; or you think it hurts your SEO or something, you can also use something like <head> position: absolute; left: -100000em;which will basically move it so far off the page, that no one would see it anyway.

The rest of the CSS
The following CSS code takes care of the appearance of the bio dropdown box.

#text-3:hover .bio-desplegable {
display: block; z-index: 99;
position: absolute; top: 25px;
background: #ccc; padding: 10px 10px 0 10px;
font-size: 11px; line-height: 18px; color: #666;
}
Explanation
r #text-3along with the :hover pseudo-class to make russian virtual mobile number the bio dropdown box appear only when you hover over the text widget.

First line: The display: block;makes the bio dropdown box visible. The z-index: 99; ensures that the box will be displayed above everything else, without any obstructions.
Second line: This positions the box below the side about 25 pixels.
Third line: These are just some cosmetic styles, setting the background to a light grey with a decent fill.
Fourth line: This is all self-explanatory typography.
Note: Regarding the first line, if you are using the technique position: absolute; left: -100000em;instead as display: none;I explained above, using <div> display: blockhere would not be necessary (since divs are already assumed to be block-level elements anyway). Instead you would need to use <div> left : 0;to move the div back onto the page.

And for the image, a simple float and right margin.

Image


.bio-dropdown .photo { float: left; margin-right: 10px; }
WordPress Integration
I can't think of a good way to integrate this into a WordPress dynamic menu (wp_nav_menuwithout leaking the crap out of something. The easiest way may be to hard code your navigation and override it (which I do on all my sites).

If you have any techniques on how to insert the markup into a WordPress menu item that is required for this, I'd love to hear in the comments. I'm sure it's possible, but it's beyond the scope of this CSS tips post.

Conclusion
Yes, I realize you probably wouldn't want to put a bio dropdown in your sidebar - you'd put it somewhere with limited space that doesn't have room for it to be fully displayed (like a narrow navigation bar).

Luckily, you can use this technique pretty much anywhere. I just wanted to go over a basic technique on how to display an entire div on hover.

It's not too complicated and you don't need any Javascript to do it, although if you wanted some high-tech fading effect, you'd probably have to use some Javascript.