Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

Here's a little bit of CSS to create a button that expands when you hover over it. I used this over at travelblog.ws to create a 'Home' button that expands to allow the user to jump directly to specific parts of the home page. All of this is using pure CSS, no JavaScript required.

This is what the button looks like normally...
hoverbtn1.png


...and when I hover over it, it expands to show two additional detail buttons...
hoverbtn2.png


The cut down version of the CSS without all the additional styling is below, but first some HTML is required. The HTML below is cut down to the bare essentials so it won't look exactly like in the screenshot. There is an outer DIV element that has an inner DIV and a link, the inner DIV holds the detail links.
 HTML
<div class="tb_home_btn">
<div>
<a href="/home"><i class="fa fa-newspaper-o"></i></a>
<a href="/journeys"><i class="fa fa-map-o"></i></a>
</div>
<a href="/home"><i class="fa fa-home"></i></a>
</div>




Lets see the CSS that makes this possible...
 CSS
.tb_home_btn div {
display: none;
}
.tb_home_btn:hover div {
display: inline-block;
}


Now the CSS is cut down again to just the bare essentials so the border, padding, etc are not shown.

The way this works is by default the inner DIV is not shown, but when the mouse cursor hovers over the home button, the inner DIV is changed to be visible. Simple!

-i

Please leave your comments or feedback below!
comments powered by Disqus
Other posts you may like...
Hi! You can search my blog here ⤵
Or browse the recent top tags...

Recent Blog Posts

How to remove caked on stickers from old game carts

How to pass parameters to your PHP script via the command line

jPhotoFrame new layout engine explained with examples

Atari Lynx Multi SD Card cartridge review

Jersey JAX-RS filters and interceptors execution order when throwing Exceptions

Why I'll never renew a domain with GoDaddy again

Fake AirPods - HBQ-i7 TWS wireless headset teardown

How to fix Postman error - Failed to import data: format not recognized

Switching out macOS Mail for Microsoft Outlook

Using DeoxIT to repair old game catridges

Recent Galleries

BMB-012 Nanoblock T-Rex Skeleton Model assembly

Tiny Arcade revision 6 kit assembly and decal application

Atari Lynx repair - Part 5 - McWill LED screen mod installation

Atari Lynx repair - Part 4 - screen cover replacement

Atari Lynx repair - Part 2 - re-capping the motherboard

Atari Lynx repair - Part 3 - broken speaker replacement

Atari Lynx repair - Part 1 - introduction and case disassembly

Building a custom Atari Lynx game box storage shelf unit in a day

Protecting old Atari Lynx game boxes with snug fit plastic sleeves

Monument Valley 2 is released and does not disappoint

Blogs and Friends

Matt Moores Blog
Georgi's FlatPress Guide
Perplexing Permutations
The Security Sleuth
Ilia Rogatchevski
Travelling Fairy

Blog Activity

Blog Activity