Is the zero-height navigation bar still apparent on the screen?

I am currently working on a portfolio website and I have a specific idea in mind for how I want the work to be displayed. I would like it to slide up onto the screen when the user clicks on the portfolio section, similar to how a navigation bar slides over when you click on a menu icon. So far, I have been successful in implementing this effect for nav bars on the right and left, but I am facing a challenge when it comes to the bottom placement, as the block still shows even when the height is set to 0.

I have tried using `display:none` and then changing it to `display:block` with jQuery, however, this approach removes the smooth animation of it sliding onto the screen.

html

        <div id="portfolionav" class="portfolionav">
            <a href="javascript:void(0)" class="closebtn" 
             onclick="closeNav2()">&#9755;</a>
            <a href="#">testing</a>
            <a href="#">Services</a>
            <a href="#">Clients</a>
            <a href="#">Contact</a>
        </div>

        <div id=bottom>
            <h1 onclick="openNav2()">PORTFOLIO</h1>
        </div>
css

        .portfolionav {
           height: 0;
           width: 100%;
           position: fixed;
           z-index: 3;
           bottom: 0;
           background-color: #111;
           overflow-x: hidden;
           transition: 0.5s;
           padding-top: 60px;
           display: block;
        }

        .portfolionav a {
           padding: 8px 8px 8px 32px;
           text-decoration: none;
           font-size: 25px;
           color: #818181;
           display: block;
           transition: 0.3s;
        }

        .portfolionav a:hover {
           color: #f1f1f1;
        }

        .portfolionav .closebtn {
           position: absolute;
           bottom: 25px;
           right: 75px;
           font-size: 36px;
           writing-mode: vertical-rl;
        }
javascript

        function openNav2() {
            document.getElementById("portfolionav").style.height = "100vh";
        }

        function closeNav2() {
            document.getElementById("portfolionav").style.height = "0";
        }

Answer №1

Opt for the display property instead of adjusting the height.

Answer №2

To ensure the portfolio div stays in place, consider using the top property instead of managing the animation based on height. Be sure to set the default height as 100vh.

Your portfolionav code should look like this:

.portfolionav {
       height: 100vh;
       width: 100%;
       position: fixed;
       z-index: 3;
       top: 100vh;
       background-color: #111;
       overflow-x: hidden;
       transition: 0.5s;
       padding-top: 60px;
       display: block;
}

For your JavaScript functions:

function openNav2() {
  document.getElementById("portfolionav").style.top = "0";
}

function closeNav2() {
  document.getElementById("portfolionav").style.top = "100vh";
}

Now, simply customize the appearance of the hand-button to your preference.

Answer №3

To show and hide navigation, you can combine the properties height and paddingTop. Setting height:0px; will hide the navigation because of the padding.

function openNav2() {
debugger;
    document.getElementById("portfolionav").style.height = "100vh";
    document.getElementById("portfolionav").style.paddingTop = "60px";
}

function closeNav2() {
    document.getElementById("portfolionav").style.height = "0";
    document.getElementById("portfolionav").style.paddingTop = "0";
}
 .portfolionav {
     height: 0;
     width: 100%;
     position: fixed;
     z-index: 3;
     bottom: 0;
     background-color: #111;
     overflow-x: hidden;
     transition: 0.5s;
     padding-top: 0px;
     display: block;
  }

  .portfolionav a {
     padding: 8px 8px 8px 32px;
     text-decoration: none;
     font-size: 25px;
     color: #818181;
     display: block;
     transition: 0.3s;
  }

  .portfolionav a:hover {
     color: #f1f1f1;
  }

  .portfolionav .closebtn {
     position: absolute;
     bottom: 25px;
     right: 75px;
     font-size: 36px;
     writing-mode: vertical-rl;
  }
        <div id="portfolionav" class="portfolionav">
            <a href="javascript:void(0)" class="closebtn" 
             onclick="closeNav2()">&#9755;</a>
            <a href="#">testing</a>
            <a href="#">Services</a>
            <a href="#">Clients</a>
            <a href="#">Contact</a>
        </div>

        <div id=bottom>
            <h1 onclick="openNav2()">PORTFOLIO</h1>
        </div>

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

How to adjust animation timing for various elements during a CSS 3D flip with a delay?

Here is a CSS flip setup that I have been working on in this fiddle: http://jsfiddle.net/6r82fzk6/ The Goal: I am trying to achieve a slower transition for the back element compared to everything else. The idea is to have the child element of the back fac ...

Improving the visualization of large GPS tracks on Google Earth Plugin

I need to display GPS routes on Google Earth using the Google Earth API. However, with approximately 20,000 points per route, the performance is not optimal. The code I have implemented successfully draws the tracks but struggles with rendering time and tr ...

implement some level of control within the ngFor directive in Angular

For instance, let's say I have an ngfor loop: <ng-container *ngFor="let setting of settings | trackBy: trackById"> <button mat-button [matMenuTriggerFor]="menu">Menu</button> <mat-me ...

Guide on setting up Tailwind CSS and material-tailwind concurrently within the tailwind.config.js configuration file

I am looking to integrate both Tailwind and Material Tailwind in a Next.js 14 project. Below is my customized tailwind.config.ts file (already configured with Tailwind CSS): import type { Config } from 'tailwindcss' const config: Config = { ...

How can the checkers code be corrected due to a mistake?

Designed a simple game where the objective is to clear all the pieces by jumping over the checkers. However, encountering an error when attempting to remove the checker for the second time. Uncaught TypeError: Cannot read property 'theRow' of u ...

How to retrieve the total count of fields in AngularJS

Could you please specify the number of choices you would like to display? For example, if the user enters 10, then 10 choices will be displayed. I have been trying to implement this functionality, but it keeps resulting in a memory error. dynamicform.jsp ...

Can the keypress event be modified within the Google Chrome browser?

My code is functioning in IE but not in Chrome. I am having issues with the event not changing. Is there a different method for achieving this in Chrome, rather than assigning specific values to the charCode, keyCode, and which variables? You can view my ...

An array containing numerous "case" triggers

var message = "hello [[xxx]] bye [[ZZZ]]" var result, re = /\[\[(.*?)\]\]/g; while ((result = re.exec(message)) != null) { switch (result[1].toLowerCase()) { case "xxx": console.log("found xxx"); br ...

Tips for maintaining wallet connectivity through page refresh with UseEffect

I am working on a function that utilizes the UseEffect to maintain wallet connectivity even when the page is refreshed. Here is the code snippet for my NavBar component: const NavBar = ({ accounts, setAccounts }) => { const isConnected = Boolean(acc ...

Using `preventDefault()` does not stop the action from occurring

Whenever I apply event.preventDefault() to a link, it works perfectly fine. But when I do the same for a button, it doesn't seem to have any effect! Check out the DEMO This is the code snippet in question: <a id="link" href="http://www.google.co ...

NextJS - Fullcalendar is experiencing issues with loading its style completely

I'm currently working on integrating FullCalendar into a Next.js 13 project (T3 Stack) and facing an issue where the style fails to load properly upon navigating back to the page containing my FullCalendar component for the second time. What I'v ...

Unable to retrieve image: status code 402 - payment required

When trying to fetch my Facebook page's posts using the Facebook graph API and nextjs with vercel, I encountered an error: GET imageurl 402 payment required. Oddly enough, this works perfectly fine in localhost: https://i.sstatic.net/JGy2g.png I sus ...

Conceal jQuery dropdown menu

Hey all you jQuery-savvy folks, have a question for you! I've got this snippet of HTML code: <div id="Layer-69" class="nav-bar nav-links"> <a href="#" title="NOSOTROS" class="nosotros">NOSOTROS</a> </div> <div id="nosotro ...

Error encountered while attempting to import the mongoose npm module into a React application

I'm encountering an issue in my React project where I am trying to include an npm module within a component. Here's an example: var mongoose = require('mongoose'); mongoose.connect('mongodb://localhost/test', {useNewUrlParser ...

I am unfamiliar with this scenario but I can utilize Axios, async/await, and TypeScript to navigate it

Having trouble creating a workflows list from an axios response Error: Argument of type 'Promise<unknown>' is not assignable to parameter of type 'SetStateAction<WorkflowForReactFlowProps[] | null>'. Here's the Axios c ...

Pop-up window for uploading files

Looking for assistance with my file uploading system. I am utilizing a unique purple button from http://tympanus.net/Development/CreativeButtons/ (Scroll down to find the purple buttons). Additionally, I am using a wide, short content popup feature availa ...

It's impossible to center text in Bootstrap 5

Creating a website for my school project has been challenging, especially when it comes to centering text. I have been struggling to position the text in the middle of the background picture despite trying various methods. Here is the HTML code: pastebin ...

Why does the DropDownList consistently remove the initial value?

I am currently in the process of developing a recipe website focused on meals. I have created an admin panel where I can manage the meals added to the site. One issue I am facing is with deleting a meal that was previously added. The menu displays the numb ...

Utilizing useEffect to retrieve and display an empty array in a React component

I am currently developing a React application that leverages Fetch to retrieve data from an API using SQLite. Strangely, when I check the console, it only displays a length of 3 and Array[0]. This means I can't access data based on specific IDs like I ...

The JQuery function assigning a value of 0 to the selectedIndex property is not functioning properly across all selected fields

<select name="wpcf-others" id="abc" class="myzebra-control myzebra-select"> <option value="wpcf-field123">General Work Jobs</option> <option value="wpcf-fields--1">Journalist/Editors Jobs</option> <option value="wpcf-4868b8 ...