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 stop macOS adding shadows to window screenshots

How to run Atari Lynx games on the SNES Classic Mini

Maven dependency scopes with relation to WAR file packaging and the WEB-INF/lib directory

Hacking the Sonoff B1 WiFi LED bulb to run custom firmware

What does an idle WebLogic server run on the hour to cause a CPU spike

How to open the Sonoff B1 wifi LED bulb to access its internal circuitry

Australian release SNES mini classic unboxing and a quick play through

Troubleshooting high CPU usage for JVM threads

How to fix WebLogic high CPU usage due to a corrupted file store

Mini review of the Sonoff B1 WiFi light bulb

Recent Galleries

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

Space Food - Chocolate Ice Cream with Chocolate Chips

Legeod Star Wars AT-DP kit

Blogs and Friends

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

Blog Activity

Blog Activity