Move the text below the fixed header position

Here is a fiddle I created to address the issue mentioned: link here

In this scenario, the header and footer are positioned absolutely with 100% width, while the middle content consists of a dashboard table. The header contains two images that when clicked, toggle the content.
When clicking on slide-toggle-1, the content of headerbottombar becomes visible.
However, the middle content is hidden and overlapped in the process.
How can we ensure that the middle content is properly displayed when clicking on slide-button-1 and slide-button-2?
Any suggestions or solutions using css, jquery, or javascript are appreciated as long as they are practical and effective.

Answer №1

If you want to adjust the position of a div, consider adding a custom class with margin-top to move it down as needed. For example:

.custom{ margin-top:50px; }

Apply this class to your div with ".box" like this:

<div class="box custom">

Then simply toggle the class on two clicks using jQuery:

$( ".box" ).toggleClass( "custom" );

You can modify the styles further based on your requirements, but this gives you a basic idea.

Answer №2

Update : For a sticky header with variable height that stays at the top, you may need to utilize some JavaScript to adjust the content's top margin dynamically.

var offset = document.getElementById("sticky-top-id").offsetHeight;
document.getElementById("content-id").style.marginTop = offset + 'px';

Source

Old Answer :

There are various methods to achieve your desired layout. One option is to set the header position to relative (and remove line breaks between header and content). Using fixed or absolute positions could cause overlap between the header and body content, whereas setting it to relative will push the content down as the header expands.

Check out this example: https://jsfiddle.net/d0pyxdoj/3/

P.S. Remember, in your code, the Header/Footer have a fixed position, not absolute.

Answer №3

Take a look at the demonstration below for how to determine height through scripting and inject spacing accordingly.

Script Example:

function calculateHeight(){
         var topHeight = $('.sticky-top').height();
       $('.content').css({"margin-top": topHeight+"px"});
     }

Sample Demo : https://jsfiddle.net/scj4u0t5/1/

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

Loading screen featuring an outlined blueprint of design elements

Can anyone identify the technology or language used to create the preloader screen on websites like the one shown in this link? The elements have a sweeping shine effect while loading. This style of preloader screen can be seen on popular websites such as ...

Having trouble retrieving information from combineLatest in Angular?

I'm having some trouble with fetching files to include in the post logs. It seems that the data is not being passed down the chain correctly when I attempt to use the pipe function after combining the latest data. This code snippet is part of a data r ...

When attempting to access an API hosted on Cloudflare from Heroku, a 403 error is returned

I am currently utilizing the Cowin API () to access available slots. My implementation is based on Node.js. Interestingly, it functions well on my local machine but encounters an error after deployment on Heroku. 2021-05-09T11:07:00.862504+00:00 app[web.1] ...

How can I pass a value from JavaScript back to the .blade file in Laravel using DataTables?

I have some rows that are being displayed: https://i.sstatic.net/Y10X7.png The DataTable plugin within app.js is responsible for outputting each row. My goal is to target a specific value, ${row.category_id} let TABLE = $('#categoryList').Data ...

Navigating between pages using React and Material UI

My concept involves a <LandingPage> with a <Top> element that can be modified by user interaction. The <Top> component contains a pageState, which can be changed by clicking buttons on the First and Second pages. Is this considered good ...

The automated test using Cucumber, Capybara, and Selenium encountered an issue when attempting to select a hidden radio button

I am currently facing an issue with checking a radio button for a form submission in RoR. The strange thing is that it works perfectly fine in development and production environments, but fails when running automated tests with Cucumber using the @javascri ...

Leveraging jQuery to dynamically load an icon based on the content within a <label> tag

I manage a website that dynamically fetches content from a database, with varying contents for each label. For example, one label may be generated as General:, while another may be generated as TV:. My question is, can jQuery be used to replace the text NA ...

Leveraging the source of an image from asset variables

Lately, I've been experiencing issues with displaying images on my page, specifically when trying to show a list of images. The problem arises when attempting to store the image URL in a variable or object instead of hardcoding it directly into the s ...

What steps can I take to prevent a JavaScript element from clearing everything when clicked?

After clicking on "add more," the first delete function works correctly, but the subsequent delete element deletes everything on the page. I suspect there may be an issue with the 'ele' variable in the JavaScript code. Since I am not very experie ...

jQuery radio button for mobile devices

I'm currently working on a web application using jQuery 1.9.1 and jQuery Mobile 1.3.2. One issue I'm facing involves horizontal radio buttons that display an icon: data-icon="radio-on". These radio buttons are dynamically added to the DOM. Her ...

A step-by-step guide to changing the color of white menu texts on a background using the multiply mix-blend

How can I ensure that the menu items have a white text color regardless of the background, while maintaining the mix-blend-mode property set to multiply? Below is an example code snippet: body {margin:0;} .navbar { overflow: hidden; background-col ...

Combining Multiple Arrays into a Multidimensional Array

I'm struggling to find information on how to combine multiple arrays of the same length into a multidimensional array. For example, I have three arrays: array1 = [value1a1, value2a1, value3a1]; array2 = [value1a2, value2a2, value3a2]; array3 = [value ...

Prevent elements from overlapping within a flexbox container

I've encountered an issue with resizing the window causing the logos to overlap the portrait image. Is there a way to fix the logos relative to the portrait? Below is the code: /* Defaults for Main Part of Pages */ body, div, h1, p { margin: 0; ...

The Bootstrap div is struggling to maintain its width on smaller screens

My attempt to create 3 inputs with the following code: <div class="col-sm-5 col-md-6"> <form> <div class="form-row"> <div class="col-0.5 search-label"> <label class="control-label">Search :</lab ...

Tips for utilizing two renderCell functions in a datagrid from Material UI without encountering duplication or repetition

Utilizing Material UI, I have designed a table to showcase my data. In this setup, I am required to use renderCell for two specific properties: 'level by user' and 'level by referent'. Issue: The problem arises when Material UI displa ...

Select only the immediate descendants of a div that are not images

Can we select only the immediate children of a div excluding images? Is there a way to achieve this using the :not-selector or any similar method? For example: http://codepen.io/anon/pen/hlrAg Incorporating a media query, I want to apply left/right-padd ...

Sending data to a JSON file with jQuery and AJAX: Step-by-step guide

While there are numerous tutorials available on how to retrieve data from json files using jQuery and ajax, I have been unable to find any that demonstrate how to POST data to a json file. If anyone has a script or example they could share with me on how t ...

How can attributes be passed to a Vue JS computed property getter and setter?

Attempting to utilize computed properties for binding input fields with the Vuex Store has presented some challenges. Each Data Stream in my application has dynamic input fields, managed through the admin section. I need to allow users to select a specific ...

ReactStrap: If the dropdown list is too long, users may have trouble viewing the final values

Currently, I'm facing an issue with a dropdown list that is taking up the entire screen and hiding some items. Here's the code snippet for reference: const statusSearchDropDownValues = ( <Row className="align-items-center"> <Col c ...

What is the method for adjusting the border color of an ng-select component to red?

I am having an issue with the select component in my Angular HTML template. It is currently displaying in grey color, but I would like it to have a red border instead. I have tried using custom CSS, but I haven't been able to achieve the desired resul ...