Sliding Background Image Menu with jQuery

Today we want to share another jQuery menu with you. This menu will have several panels, each one corresponding to a different background image that will show on all panels when we hover over a panel label. Also, a submenu will slide out from the bottom. This menu comes with some configuration possibilities, such as size of the image, the hover effect and custom default states.
SlidingBackgroundImageMenu

From our monthly sponsor: monday.com, a new way to manage your work! Meet the new visual project management tool.

Today we want to share another jQuery menu with you. This menu will have several panels, each one corresponding to a different background image that will show on all panels when we hover over a panel label. Also, a submenu will slide out from the bottom. This menu comes with some configuration possibilities, such as the size of the image, the hover effect and custom default states.

The idea of this navigation is based on the Beautiful Background Image Navigation with jQuery, a tutorial that had a similar effect. Since it was very popular and a lot of our readers asked for some very useful additions, we decided to revamp it and make it easier to customize.

The beautiful gastronomy photography is by Manoel Petry:
Manoel Petry’s Flickr Photostream
Manoel Petry’s Website
The images are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.0 Generic License.

Examples

Take a look at all the examples (you can also navigate from them to all the other demos):

The HTML structure consists of the “sbi_container” which will have all the panels inside:

<div id="sbi_container" class="sbi_container">
	<div class="sbi_panel" data-bg="images/1.jpg">
		<a href="#" class="sbi_label">About</a>
		<div class="sbi_content">
			<ul>
				<li><a href="#">Subitem</a></li>
				<li><a href="#">Subitem</a></li>
				<li><a href="#">Subitem</a></li>
			</ul>
		</div>
	</div>
	<div class="sbi_panel" data-bg="images/2.jpg">
		...
	</div>
	...
</div>

The “data-bg” attribute contains the path to the background image that will appear when hovering over the label of the respective panel.

Let’s take a look at an example for using the alternating vertical up/down sliding effect:

$('#sbi_container').bgImageMenu({
	defaultBg	: 'images/default.jpg',
	menuSpeed	: 300,
	border		: 1,
	type		: {
		mode		: 'verticalSlideAlt',
		speed		: 450,
		easing		: 'easeOutBack'
	}
});

The following parameters can be used/set:
defaultBg: the default image shown when no label is hovered
pos: if no defaultBg set, pos will indicate the panel that should be shown/open
width: the width of the container and the images (they should all be of the same size)
height: the height of the container and the images
border: the width of the margin between the panels
menuSpeed: the speed with which the menu should slide up

mode: the type of animation; you can use def | fade | seqFade | horizontalSlide | seqHorizontalSlide | verticalSlide | seqVerticalSlide | verticalSlideAlt | seqVerticalSlideAlt
speed: the speed of the panel animation
easing: the easing effect for the animation
seqfactor: delay between each item animation for seqFade | seqHorizontalSlide | seqVerticalSlide | seqVerticalSlideAlt

We hope you find this little menu interesting and useful, enjoy!

Previous:
Next:

ML is a freelance web designer and developer with a passion for interaction design. She studied Cognitive Science and Computational Logic and has a weakness for the smell of freshly ground peppercorns.

View all contributions by

Website: http://www.codrops.com

Related Articles

Receive our bi-weekly Collective or official newsletter right in your inbox.

Which newsletter would you like to receive?

CSS Reference

Learn about all important CSS properties from the basics with our extensive and easy-to-read CSS Reference.

It doesn't matter if you are a beginner or intermediate, start learning CSS now.

Feedback 90

Comments are closed.
  1. 2

    Hi there, I am kinda new to this but I love your stuff, can you tell me how I would position this menu on the page.

    And thanks

  2. 6

    Hi, it seems that the script doesn’t support width in %

    How can I solve that to adjust the width to the screen size (width and height).

    http://goo.gl/cFjFH

    Thank you very much and compliments for the script!

  3. 8

    Hi Andrew, thank you very much for your answer! Unfortunately in the jquery.bgImageMenu.js the sizes there are only in px and not in %

    I can’t figure out the solution ;(

    Do you have any idea?

  4. 9

    Awesome !

    default background / pos

    would it be possible to either have an ‘on load’ background, which appeared on load but would not return on mouse out, as the default background does, or alternatively if using pos, not display the sumbenu items by default

  5. 10

    If you use style on the html div for the menu height it will crash in Chrome.

    However if you use the ascii code for spaces in the menus it will not make that bottom big gap and displays perfectly. 😉

  6. 11

    I have been experimenting with Sliding Background Image Menuwith jQuery.
    I have noticed that if one swipes their mouse across a menu, causing the background image to change, it stays locked. The original (primary) background image does not return.

  7. 12

    Same with me. It would be very nice, if one could solve this problem… Great work though!!!

  8. 13

    First of all, thanks a lot for this great tutorial!

    but, please, I need your help. I was testing my panel in Firefox, IE 9 and Chrome. It doesn’t work in Chrome (15.0.874.121 m).

    Please, look it at:
    http://www.sj.uphero.com
    http://www.sj.uphero.com/2/example3.html

    The problem is that the jQuery animation effect works fine in Firefox an IE, but it’s not working in Chrome a tall, and it only shows the panels (without any animation….)

    Please, help me and again, thanks for your post!

    • 14

      Hi Seba,
      I just looked at the pages and it works fine for me, but I have version 16.0.912.63 m which is the latest stable release. Can you check in the console if any errors show up? When you are in Chrome, just hit F12 and click on “Console”. Hope it helps somehow, cheers, ML

  9. 15

    I did some changes in the script’s options ( ‘speed’ in 400 and ‘seqfactor’ in 400 ) and now it’s working better, but I’m not convinced.

    The console doesn’t show any errors, so I’m going to assume that chrome has a diference in the interpretation of the easing effect, or something like that.

  10. 16

    is there any posibility to move the panels in an automated way? That would be a great beahvior!

  11. 19

    Beautiful Plugin !

    I’m thinking of using this for the site of a local folk artist. She has no intention of selling her work currently but may in the future. I notice the license is “non-commercial”. If I use this, will we have to remove it if she begins to sell her work ? (Also, how do you like to be attributed ?)

    Thanks much – great work !

  12. 20

    Hello –
    When making the submenus, if I name one Our Mission, the submenu adds an additional Line, meaning its interpreting the whitespace as a line. This is observed in both IE9 and Chrome. Any advice/help?

  13. 21

    HI
    Any one knows if it works on IE9. I tested on my page with this Beautiful Plugin, but it didn’t work on IE9.
    It is too bad to me. I really like to use it on my site. Please help me if anyone know how it works on IE9.

    Thanks

    June

Comments are closed.