Include a "sturdy" div within a dynamic footer navigation bar

Looking for ways to enhance the responsive menu at the bottom of a webpage? Consider centering the copyright div at the bottom of the screen without being obstructed by menu items. As the browser window shrinks, ensure that the copyright statement remains visible and then seamlessly repositions below the menu items when they overlap or when the menu expands after being minimized.

function myFunction() {
  var x = document.getElementById("myNavbar");
  if (x.className === "navbar") {
    x.className += " responsive";
  } else {
    x.className = "navbar";
  }
}
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.navbar {
  overflow: hidden;
  background-color: #333;
  position: fixed;
  bottom: 0;
  width: 100%;
}

.navbar a {
  float: right;
  display: block;
  color: #f2f2f2;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

.navbar a:hover {
  background-color: #ddd;
  color: black;
}

.navbar a.active {
  background-color: #04AA6D;
  color: white;
}

.navbar .icon {
  display: none;
}

#copyright {
  position: absolute;
  top: 20%;
  left: 25%;
  width: 50%;
  height: 50%;
  color: white;
}

@media screen and (max-width: 600px) {
  .navbar a:not(:first-child) {
    display: none;
  }
  .navbar a.icon {
    float: right;
    display: block;
  }
}

@media screen and (max-width: 600px) {
  .navbar.responsive .icon {
    position: absolute;
    right: 0;
    bottom: 0;
  }
  .navbar.responsive a {
    float: none;
    display: block;
    text-align: left;
  }
}
<!DOCTYPE html>
<html>

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>

  <div class="navbar" id="myNavbar">
    <div id="copyright">© domain.com</div>
    <a href="#home" class="active">Home</a>
    <a href="#news">News</a>
    <a href="#contact">Contact</a>
    <a href="#about">About</a>
    <a href="javascript:void(0);" style="font-size:15px;" class="icon" onclick="myFunction()">&#9776;</a>
  </div>

  <div style="padding-left:16px">
    <h2>Responsive Bottom Navbar Example</h2>
    <p>Resize the browser window to see how it works.</p>
  </div>

</body>

</html>

Share your thoughts on improving this setup!

Answer №1

Thank you for pointing out the issue with how it was displaying on your browser. I have made some adjustments to ensure better browser support and added comments for clarity.

  function myFunction() {
    var x = document.getElementById("myNavbar");
    if (x.className === "navbar") {
      x.className += " responsive";
    } else {
      x.className = "navbar";
    }
  }
/*
* Prefixed by https://autoprefixer.github.io
* PostCSS: v8.3.6,
* Autoprefixer: v10.3.1
* Browsers: last 7 version
*/

  /*
  Body
  */

  body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
  }

  /*
  The Navigation Container/Block
  */

  .navbar {
    background-color: #333;
    position: fixed;
    bottom: 0%;
    right: 0%;
    width: 100%;
  }

  /*
  Grid Container
  */

  .grid-container {
    display: -ms-grid;
    display: grid;
    -ms-grid-columns: 1fr 1fr 1fr;
    grid-template-columns: 1fr 1fr 1fr;
  }

  /*
  Item 1
  */

  .item-1 {
    text-align: end;
  }

  /*
  Item 2
  */

  .item-2 {
    color: white;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
        -ms-flex-align: center;
            align-items: center;
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
  }

  /*
  Item 3
  */
  
  // more styles...

<!DOCTYPE html>
<html>

// other HTML content

</html>

Answer №2

Take a look at this potential solution:

function adjustNav() {
  var nav = document.getElementById("myNavbar");
  if (nav.className === "navbar") {
    nav.className += " responsive";
  } else {
    nav.className = "navbar";
  }
}
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
}

.navbar {
  overflow: hidden;
  background-color: #333;
  position: fixed;
  display: flex;
  justify-content: center;
  bottom: 0;
  width: 100%;
}
...
<!DOCTYPE html>
<html>

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body>

  <div class="navbar" id="myNavbar">
    <div id="copyright">© domain.com</div>
    <a href="#home" class="active">Home</a>
    <a href="#news">News</a>
    <a href="#contact">Contact</a>
    <a href="#about">About</a>
    <a href="javascript:void(0);" style="font-size:15px;" class="icon" onclick="adjustNav()">&#9776;</a>
  </div>

  <div style="padding-left:16px">
    <h2>Responsive Bottom Navbar Example</h2>
    <p>Resize the browser window to see how it works.</p>
  </div>

</body>

</html>

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

"Interactive demonstration" image toggle through file upload

I have a project to create a "demo" website for a client who wants to showcase the template to their clients. A key feature they are interested in is allowing users to upload their logo (in jpg or png format) and see it replace the default logo image insta ...

Is there a specific technological framework that serves as the foundation for the development of the Google Body Browser

I'm looking for some insight into the framework used to develop Google Body browser. Can anyone provide more information? So far I know it involves WebGL and Javascript, but I'm curious whether they utilize a GWT extension for WebGL interaction ...

Creating equal height nested columns in Bootstrap 3 Grid: ensuring all nested columns are uniform in height

Struggling to make sure all columns in Bootstrap 3 are the same height throughout the page? If you've managed to achieve this with 3 columns, like the example provided here, great job! However, the challenge arises when dealing with nested columns t ...

Create a stunning border image with a touch of transformation

Dealing with a button dilemma here. The client wants the border to also be the image, which is creating quite the challenge for me. Changing the box is no problem, but the tricky effect on the next button is preventing me from making the necessary adjustme ...

Upon implementing a catch-all express routing solution, the Fetch API calls are no longer successful. The error message received is "Unexpected token < in JSON at

While working on a React project, I encountered an issue outlined in this link: React-router urls don't work when refreshing or manually typing. To resolve this problem, I decided to implement the "Catch-All" solution recommended in that discussion. ...

Is it feasible to create a self-contained HTML document that can interact with client serial ports through JavaScript?

Is it feasible to execute a client-hosted HTML file (including scripts) that can interact with the computer's serial ports? I'm looking for a portable 'applet' that can be used to configure a device connected via serial communication u ...

What is the best way to display values from a Localstorage array in a tabular format using a looping structure

I have set up a local storage key 'fsubs' to store form submissions as an array. Here is how I am doing it: var fsubs = JSON.parse(localStorage.getItem('fsubs') || "[]"); var fcodes = {"barcodeno" : this.form.value.barcode, "reelno" : ...

Horizontal order with Flexbox

I'm currently utilizing flexbox to arrange elements in a row <div class="artist-wrapper"> <div class="artist"></div> <div class="artist"></div> <div class="artist"></div> </div> .artist-wra ...

What is the technique for refining the exterior of an element while remaining within its parent container?

I need help with two elements that I have set up like this. .parent { height: 300px; width: 300px; background-image: url("https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/Icecat1-300x300.svg/2048px-Icecat1-300x300.svg.png"); backgrou ...

Alter attribute with an impact

I am looking for a solution to switch the image source using attr, while also incorporating a fade effect in the process. I have attempted to implement one of the suggestions from another post, but it is not producing the desired outcome. Current Appearan ...

Using jQuery selectors to assign a value to a particular text input field with a matching name

Is it possible to set only the file name field that matches each file input field? I have three text input fields with the same name and three text fields for the file names. function getFileData(myFile){ var file = myFile.files[0]; var filename = ...

Converting an array into a duplicate key object using Node.js - Learn how!

I am looking to transform an array into a duplicate key object in Node.js. Here is the array data I have: { "name" : "ashesh", "address_data" : [ { "city" : "Mumbai", "pincode": "400097" }, { ...

There was a problem retrieving the product information from the API

I have been struggling to pinpoint the exact issue at hand. The foundation of HTML and CSS is pre-written, with JavaScript responsible for generating the core elements to populate the DOM. Within my script, I am attempting to retrieve product data in ord ...

Ensuring javascript object is appropriately escaped

If you have an object like {"key":"pairs","are":"fun"} that is assigned to a variable with PHP like this: const foo = <?php echo $bar ?>;, what is the correct method to escape the object? I have attempted using encode_json which escapes all the dou ...

Anchor validation across various spans

Here is the HTML code snippet I am working with: <p class="main-text"> <span>Lorem Ipsum</span> <span>Lorem Ipsum</span> <span>Lorem Ipsum</span> <span>Lorem Ipsum</span> ...

Resource loading unsuccessful: server returned a 405 status code, indicating method not permitted

An error occurs when attempting to send an email using PHP. Failed to load resource: the server returned a 405 (Method Not Allowed) status for sendmail.php This is the form: <form action="sendmail.php" method="post" id="contactform" > <div ...

Issue with jQuery .ajax() not triggering success callback function when using JSONP

My Facebook iframe application is attempting to make a cross-domain request to my server for JSONP data. The client-side code I am using is as follows: jQuery.ajax({ url: '***', type: 'post', ...

Retrieving a specific value from a collection of nested arrays containing objects

Having trouble extracting values from fields and have tried various methods like nesting the map function and concatenating fields without success. I have an object with a structure similar to this: [{ name: 'sean', age: 26, address: ...

Object attribute of textgeometry

Currently, I am immersed in a project that involves creating web components using Three.js. One of the challenges I face is generating objects for these components, particularly those with text attributes. My goal is to encapsulate the text mesh within a T ...

Can you explain the functionality of the Json onLoad method and how can I use it to send a response?

function MakeJsonRequest() { JsonRequest.setRequestHeader("Content-type", "application/json"); JsonRequest.send(Data); JsonRequest.onload = function() { ProcessJsonResponse(this.responseText); } } // The Som ...