What is the best way to display my menu bar when the icon is hovered over?

I want to create a menu bar similar to the one found on . I am unsure of how they achieved this effect, but it seems to involve a scroll-over action. However, when I attempt to replicate it, the words still appear even when the menu bar is collapsed.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>

<!-- SlideBars Meta-->
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- END SlideBars Meta-->

<!-- This is the SlideBar CSS link-->
<link rel="stylesheet" href="CSS/slidebars.min.css">
<link href="CSS/Main.css" rel="stylesheet" type="text/css">
<!-- END SlideBar CSS link-->
</head>

<body>

<nav class="navbar navbar-default navbar-fixed-top sb-slide" role="navigation" style="webkit-transform: translate(381px);">
    <a class="hidden-phone"><!-- Main navigation menu bar appears when desktop version is available-->
        <div class="main-nav">
            <div class="navicon-line-padding">
                <div class="navicon-line"></div>
                <div class="navicon-line"></div>
                <div class="navicon-line"></div>
            </div><!-- END navicon-line-padding-->
            <ul class="main-nav-li">
                <li>Home</li>
            </ul><!-- End Main-nav-li-->
        </div><!--End Main-nav-->
    </a><!-- End hidden-phone-->

    <a id="nav-open-btn" class="visible-phone" rel="track-event" data-ga-action="Mobile Menu" href="#">
        <div class="sb-toggle-left navbar-left">
            <div class="navicon-line"></div>
            <div class="navicon-line"></div>
            <div class="navicon-line"></div>
        </div>
    </a><!--END nav-open-btn-->



<!-- This Div is in place to make the MenuBar Work properly do not move-->
<div id="sb-site">
<p>

</p>

</div>
</nav>
<!-- END Sb-site Div-->

<!-- This is the SB-SlideBar Left Div-->
<div class="sb-slidebar sb-left sb-style-push sb-toggle-left">

    <nav>

      <ul class="sb-menu">

            <li class="SquirrelIcon">
                <a href="#"><img src="imgs/FurrySquirrelLogo2.png" width="300"  height="174" alt="Furry Squirrel Productions"></a>
            </li>

            <li>
                <a href="#" class="LinkItemMenu">Home</a>
            </li>

        </ul>

    </nav>

</div><!-- END sb-slidebar sb-left div-->

<!-- Start SlideBar JQuery-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">   </script>
<!-- END SlideBar Jquery-->

<!-- Start SlideBar JS-->

<script src="JS/slidebars.min.js">
</script>

<script>
  (function($) {
    $(document).ready(function() {
      $.slidebars();
    });
  }) (jQuery);
</script>

<!-- END SlideBar JS-->

</body>
</html>

Here is my CSS code:

@charset "utf-8";
/* CSS Document */

.navicon-line {
background-color: #000;
height: 4px;
width: 24px;
margin-bottom: 3px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
}
.sb-toggle-left.navbar-left {
padding: 14px;
z-index: 1030;


top:
;
width: auto;
position: fixed;
}
.navbar.navbar-default.navbar-fixed-top.sb-slide {
position: fixed;
z-index: 1303;
left: 0px;
top: 0px;
height: auto;
width: 100%;
}

.SquirrelIcon {
margin-top: 20%;
margin-bottom: 20px;
margin-left: 5%;
margin-right: 5%;
}
.sb-menu .SquirrelIcon a img {
height: auto;
max-width: 100%;
}
#sb-site p {
width: 300px;
}

@media screen and (max-width: 43.125em) {
.visible-phone {
   display: inherit !important;
}

.hidden-phone {
  display: none !important;
}

}
.main-nav-li {
font-family: Arial, Helvetica, sans-serif;
font-size: 1.5em;
color: #000;
text-decoration: none;
list-style-type: none;
}
.main-nav:hover {
height: auto;
width: 100%;
background-color: #0C0;
position: fixed;
left: 0px;
top: 0px;
}
.hidden-phone {
height: auto;
width: 100%;
}
.navicon-line-padding {
padding: 14px;
}

I am trying to ensure all items are invisible unless the user scrolls over the icon, at which point they should become visible.

Answer №1

Hello there, I'm Adam and I wrote Slidebars :)

It seems like the link you shared isn't working, so I'll have to make an educated guess about what you're trying to accomplish.

There are a couple of issues with your code. Firstly, your #sb-site container should be outside of your navbar, not within it. So your corrected markup should look something like this:

<body>
    <nav class="navbar"></nav>
    <div id="sb-site"></div>
    <div class="sb-slidebar sb-left"></div>
</body>

If you don't want the navbar to move, simply remove the .sb-slide class and the plugin won't animate the navbar for you.

If your navbar is supposed to stay still and you want to achieve a hover effect, it's quite simple with Slidebars' API. I've created a JSFiddle to demonstrate how to do this:

http://jsfiddle.net/7YzF4/

I hope this explanation helps you out!

Thanks for using Slidebars, Adam

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Checkbox option to change background color of table cell

$('#selectall1').click(function(event) { if (this.checked) { $('.first').each(function() { this.checked = true; }); $('.second').each(function() { this.checked = false; }); $('.third&apos ...

Unseen components and columns with Bootstrap 4

I am attempting to hide a checkbox input in the middle of some column elements using Bootstrap 4. <div class="container"> <div class="row"> <a class="col-2"> 1 of 2 </a> <input type="checkbox" class="invisibl ...

Is there a way for me to set distinct values for the input box using my color picker?

I have two different input boxes with unique ids and two different color picker palettes. My goal is to allow the user to select a color from each palette and have that color display in the corresponding input box. Currently, this functionality is partiall ...

How come I am unable to connect my CSS to my EJS files?

Having difficulty linking my css files to my ejs files. Using a standard node.js/express setup, I'm attempting to connect my main.css file from the public/css directory to my index.ejs file in views. The html and routing are functioning correctly. Ple ...

Is there a way for a DOMWindow popup to automatically resize to fit its

Currently exploring JQuery and learning on the fly, I'm wondering if there's a method to automatically adjust the size of a DOM window based on its content? I've successfully modified the parameters to accept % width and height instead of p ...

The error form is not responding even after attempting to locate the issue

I have created a form and it was working fine, but now when I click on the submit or reset buttons, nothing happens. I've checked my code thoroughly line by line, but can't seem to find the issue. I even tried restoring previous versions, but no ...

Utilizing Scrollify for seamless section scrolling with overflow effects

I have been experimenting with the Scrollify script (https://github.com/lukehaas/Scrollify) and facing an issue where my sections are longer than the user's screen, requiring them to scroll down to view all content. However, Scrollify doesn't al ...

Chrome displaying an extJs Button image

Could it be that Chrome is evolving into the new IE in terms of CSS issues? Here is the code I have for creating ExtJS buttons within an accordion: var button = Ext.create('Ext.Button', { text: '<img src="'+resp.sellers.externa ...

Steps to troubleshoot the TypeError: cv.Mat is not a constructor in opencv.js issue

Encountering a problem while trying to use opencv.js for detecting aruco markers from my camera. Each time I attempt to utilize the method let image = new cv.imread('img'); An error keeps popping up: TypeError: cv.Mat is not a constructor ...

What is the best way to apply typography theme defaults to standard tags using Material-UI?

After reading the documentation on https://material-ui.com/style/typography/ and loading the Roboto font, I expected a simple component like this: const theme = createMuiTheme(); const App = () => { return ( <MuiThemeProvider theme={theme}> ...

Unable to reach the margin-left properties of the elements

I am facing an issue in accessing the current margin-left CSS property of the class .circle in the code snippet below. A demonstration of this problem can be found on a website called PLUNKr. The reason I need to access this property is because I have to ...

Ensure that the heights of columns in UL CSS are aligned regardless of the number of lines they contain

In my current project, I am using CSS columns to establish a two-column layout for an unordered list. Here is the code snippet: HTML <div class="meta-data"> <ul> <li><i class="fa fa-chevron-right fa-xs"></i><str ...

React component is unable to identify prop

I'm attempting to send an array of objects from the main App.js file to a smaller component using props. However, for some reason, the prop is not being recognized within the smaller component file. https://i.stack.imgur.com/WuyFr.png https://i.stac ...

What is the best way to redirect to a specific page when logging out of a website?

To begin, let me outline the situation at hand. We have two distinct websites - website-A and website-B. Each of these websites is hosted on separate domains. A user has the ability to log in to website-B's homepage through the login page of webs ...

The styling of Bootstrap CSS is not displaying correctly within the body of the webpage

I'm facing an issue where the content in the body of my page is not rendering correctly due to a problem with my bootstrap css. Specifically, the paragraph tag seems to be rendering inside the image tag even though both are within the body. @{ Lay ...

Incorporate a personalized style into the wysihtml5 text editor

Is there a way for me to insert a button that applies a custom class of my choice? I haven't been able to find this feature in the documentation, even though it's a commonly requested one. Here's an example of what I'm looking for: If ...

What's the best way to fix a div to the bottom left corner of the screen?

I have explored various solutions regarding this issue, but none of them seem to meet my specific requirements. What I am trying to achieve is the correct positioning of a div as depicted in the green area in the image. The div located above the green div ...

Setting line height as a pixel value does not yield the desired result

$(element).css(options.css).attr(options.attr).addClass(options.class) //ensure line-height is correctly assigned if($(element).is('p') && _.isString(options.css['line-height'])){ console.log('line-height assigned: &apos ...

I have implemented an email validation form in Angular, however, if the validation is not properly handled, the data will still be stored. How

When I enter an email address, for example: if I enter "abc" it shows an alert saying "please enter a valid email". If I leave it blank and try to submit, it shows an alert saying "email required". But when I click register, the data is saved regardless of ...

Changing images dynamically using Javascript when hovering over an element

Looking to create a dynamic image switch effect on hover, where multiple images cycle through when hovered over. Each time the mouse hovers over the image, it should switch to the next in a sequence of 5 images. <img id="switch" src="img1.jpg"> $(& ...