What is the best way to position a div directly over another div at the bottom of the page

I am facing an issue on my web page where I have a navigation bar always at the bottom of the page. However, I also have another

<div style="display: block;" id="detail">
that currently hides the navigation bar. I want both divs to be visible and aligned properly. Can anyone guide me on how to position the
<div style="display: block;" id="detail">
exactly on top of the navigation bar?

To clarify, here is the link to the jsfiddle with just the navigation bar:https://jsfiddle.net/4mwdkr3p/

And here is the link to the jsfiddle with both div elements (where the navigation bar becomes invisible):https://jsfiddle.net/aq13uwua/2/

[CSS Code Here]
[HTML Code Here]

Edit(detail): I am developing a web app for iOS where I need a persistent navigation bar at the bottom of each page. The detail div contains buttons for playing videos and audio, as well as an image button for adding the current video to favorites. When this favorite button is clicked, its image changes via JavaScript to indicate that it has been added to favorites. However, the issue is that this favorite image button overlaps and hides the navigation bar below it. My goal is to position the favorite button above the navigation bar so that both are visible simultaneously.

Answer №1

In your HTML code, you are utilizing an element with id "FavKey" and setting its position to fixed at the bottom of the browser window using CSS properties like position: fixed; and bottom: 0px;. To make sure this element is positioned relative to its parent container (in this case, #detailContainer), you should change its positioning to absolute by adding position: absolute;. By doing so, when you set bottom:70px; on the #detail element, you will be able to see the navigation properly.

ul#navigation {
  height: 70px;
  /* additional styles */
}
/* other CSS rules specific to the navigation bar */

#MenuContainer {
  text-align: center;
  margin: 50px auto;
}
/* other CSS rules for MenuContainer */

#detail {
  display: none;
  /* additional styles */
}
/* other CSS rules for detail */

#detailContainer {
  display: block;
  /* additional styles */
}
/* other CSS rules for detailContainer */

.centerKeyContainer {
  display: block;
  /* additional styles */
}
/* other CSS rules for centerKeyContainer */

.first {
  display: inline-block;
  /* additional styles */
}

.second {
  display: inline-block;
  /* additional styles */
}

#FavKey {
  display: block;
  /* additional styles */
}

.addedFav {
  display: block;
  /* additional styles */
}
<div style="display: block;" id="detail">
  <div id="detailContainer">
    test
    <img src="./imageone.png"><b> Mango</b>
    <br>
    /* other HTML content */
  </div>

</div>

<div id="MenuContainer">

  <ul id="navigation">
    <li class="x">
      <a title="1" href="./test.php">
        <img id="myButton1" src="./1.png" alt="" border="0" height="42" width="42">
        <div class="caption">1</div>
      </a>
    </li>
    /* more list items */
  </ul>
</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

Discovering the method for retrieving JavaScript output in Selenium

Whenever I need to run JavaScript code, the following script has been proven to work effectively: from selenium import webdriver driver=webdriver.Firefox() driver.get("https:example.com") driver.execute_script('isLogin()') However, when I atte ...

Update the href attribute when a button is clicked

Note: The buttons in the corner will not be submitting the search. The go button would still need to be clicked to submit it. Currently, I am working on a fun project during my free time at work. This project is not meant to be anything serious, but rathe ...

Picture fails to load on iPad/iPod devices

My website is working perfectly, but I have encountered an issue when trying to view it on devices like iPod/iPad. The image of the elephants either doesn't show up at all or appears for a split second before disappearing. I've read other threads ...

Interpreting HTML using a PHP script and running PHP commands embedded in the file

Does anyone know how to execute PHP code within an HTML file that is being opened inside a PHP file? Here's the scenario: I have an HTML file structured like this: <html> <head> <title></title> </head> ...

Looking to create a sophisticated HTML table design

Struggling to design an HTML table like the one shown in the attachment below due to a lack of understanding. My attempt so far is far from satisfactory, seeking guidance to point me in the right direction. <section class="mb-5"> <div ...

How to move content without affecting the background of the `<body>` using scrolling

Can I achieve a glass morphism effect on my page without moving the background of the body? I only want to move the .container. Is this feasible? I attempted using background-attachment: fixed, but it did not work for me. Here is the code snippet I have be ...

Issue with div in simple HTML code

I've been facing challenges with this line of HTML as I keep encountering errors and cannot pinpoint the source. The error highlight appears at the end of the last div, but once removed, another error emerges at the end of the body tag. Check out the ...

ng-class in AngularJs updates the class of all items within ng-repeat in the view

When applying AngularJs' ng-class, I encounter an issue where the class gets updated and applied to all items in the ng-repeat directive instead of just the specific item that was clicked. Even when using data-target="#collapse_{{ $index }}", it does ...

Using a Do/While loop in combination with the setTimeout function to create an infinite loop

Having trouble with this script. The opacity transition works fine, but there seems to be an issue with the loop causing it to run indefinitely. My goal is to change the z-index once the opacity reaches 0. HTML <div class="ribbon_services_body" id="ri ...

Obtaining table data and HTML elements using the correct code - Selenium and Python

I've been attempting to extract the ticker symbol, stock name, price, sector, and market cap columns from this website. I'm facing challenges in identifying the correct HTML elements using the appropriate code. Although I've used Selector Ga ...

Filestack - NoCrop: Utilize whitespace to maintain the square aspect ratio when uploading images without cropping

Is there a way to use Filestack to upload an image and automatically add whitespace to the sides of the image in order to keep it square without cropping? click here for image ...

What is the best way to access a child element from a parent element in HTML?

I am facing an issue with my HTML page where I have an element that opens a bootstrap modal and a button inside the modal launch div that displays an alert when clicked. The problem arises when the alert is displayed, and upon closing it, the modal also ...

Add the AJAX response to a div element when the submit button is pressed

Working on a WordPress project involving an AJAX call, I need to return the result of a row to a div with the ID #hero. The challenge is that since the result is inside a for loop and each row has its own hero div, I want the result to be returned to the c ...

Displaying a loading screen while a jQuery ajax request is in progress

Currently, I am attempting to display a loading div while waiting for an ajax call to finish. Despite experimenting with various methods, I have not been able to consistently achieve the desired outcome. In my present code, everything functions properly o ...

Click on the span to smoothly navigate to a specific div

I am attempting to implement a feature where clicking on "move to" will smoothly scroll the page up to a container division. However, I am encountering issues with this functionality not working as intended. Below is a code snippet showcasing my current i ...

Vue's v-for modifies the initial element within the list

I currently have a vue pinia store called "cartStore": import { defineStore } from 'pinia' export const cartStore = defineStore('cart', { state: ()=>({ cart: [] }), actions:{ async updateQuantity(id,logged,inc){ ...

What are some creative ways to enhance closePath() in canvas styling?

Currently, I am faced with the challenge of styling the closePath() function on my canvas. Specifically, I would like to apply different stroke styles to each line segment. For now, let's focus on changing colors for each line. In the example below, y ...

Tips for maintaining proper alignment of the element within the given space and organizing it vertically with appropriate spacing

I am trying to align the elements so that they take up the available space and stay vertically arranged in the same order, but I'm having trouble achieving this. Is there a way to accomplish this? Here is my code: .parent { border: 1px solid red; ...

Is it possible to use font-face in CSS3 to switch fonts for different languages?

Can I replace an Arabic font with a custom one using font-face in CSS3? I've successfully done it with English but I'm not sure if it's the same for foreign languages, so I wanted to check. Also, I feel silly asking this question, but I&apos ...

The switchView feature is currently malfunctioning and unable to access the content on the next page

For my application's admin panel design, I've divided my home into containers. The aim is to display details of clicked items in Images.html and Categories.html when a menu item in the 2nd container (also known as side bar) is clicked. However, m ...