Three fixed position divs arranged horizontally side by side

I am attempting to organize 3 divs in a row using Flex.

ISSUE 1: The div that is centered is set with position: fixed. However, the two other divs on each side do not stay aligned with the centered fixed div when scrolling. If I change the centered div to position: sticky, it moves down to the middle of the page instead of staying at the top.

ISSUE 2: Additionally, there is a shape element positioned behind these 3 divs. The intention is for the two side divs to be placed beneath the shape by setting z-index: -1 on both sides, but this was unsuccessful.

The padding on the two side divs is set to padding-top: 450px in order to keep the content lower than the centered div, as depicted in the prototype screenshot.

(UPDATED) - JSFiddle for the SECOND ISSUE.

This Adobe XD prototype showcases how it should appear -

(UPDATED) - https://i.sstatic.net/BUHV8.png

Your assistance is greatly appreciated!

html,
body {
  width: 100%;
  margin: 0 auto;
  padding: 0;
  background-color: #12212A;
}

.body-wrapper {
  position: absolute;
  margin: 0 auto;
  width: 100%;
  background: #12212A;
  display: flex;
  align-items: center;
  justify-content: center;
}

.row-profile {
  color: white;
  border: #3D4B57 solid 1px;
}

.body-wrapper>.row-profile {
  flex: 1 1 30%
}

#profile-left {
  text-align: right;
  padding-right: 44px;
  padding-top: 450px;
  height: 1520px;
  width: 455px;
  background-color: #12212A;
}

#profile-center {
  text-align: center;
  background-color: #3D4B57;
  padding-top: 0;
  top: 0;
  margin-top: 0;
  width: 366px;
  height: 250px;
  position: fixed;
}

#profile-right {
  padding-left: 44px;
  padding-top: 450px;
  height: 1520px;
  width: 455px;
  background-color: #12212A;
}
<div class="body-wrapper">
  <div class="row-profile" id="profile-left">LEFT (content see JSFiddle link)</div>
  <div class="row-profile" id="profile-center">CENTER LEFT (content see JSFiddle link)</div>
  <div class="row-profile" id="profile-right">RIGHT (content see JSFiddle link)</div>
</div>

Answer №1

Regarding the second issue - the actual shape itself:

.body-wrapper::before{
    content: '';
    position: absolute;
    left: 0;right: 0;
    height: 200px;
    background: red;
    z-index: 10;
}

To ensure that the center element is positioned above the shape, increase its z-index value:

#profile-center{
    z-index: 20;
}

If you want the shape to remain fixed at the top of the viewport, switch position:absolute to position:fixed.

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

What steps can be taken to properly display dateTime values in a data table when working with JavaScript (VueJS) and PHP (Laravel)?

I am facing an issue where I am unable to save user inputted date-time values from a modal into a data table. Despite receiving a success message, the dateTime values are not being added to the table. My payload only displays the state and approval fields ...

Embedding a CSS file into a PHP class

I've encountered a little issue that I can't seem to solve on my own. I've put together a "webengine" using multiple classes. The primary class responsible for obtaining a theme's internals is called "Logic". This Logic class contain ...

Unexpected output from Material UI Textfield

When attempting to print a page of my React app using window.print(), everything prints correctly except for the Textfield component from Material UI. It works fine when there are only a few lines of text, but when there is a lot of text, it appears like t ...

What is the proper way to format lengthy lines in Twig templates while adhering to coding standards?

In my templates, I have the following code snippet for generating routes with parameters: <a class="btn btn-block btn-abcd" href="{{ path( 'auth.login', { 'type': constant('User::TYPE_CANDIDATE'), & ...

Parsing Json data efficiently by utilizing nested loops

I have 2 different collections of JSON data, but I'm unsure of how to utilize JavaScript to parse the information. Data from API1 is stored in a variable named response1: [{"placeid":1,"place_name":"arora-square","city":"miami","state":"florida","c ...

Is there a tool available for viewing the HTML5 Web SQL database?

Is there a tool available, such as PHPMyAdmin, that allows users to easily view HTML5 Web SQL databases from their web browser? ...

The error message "TypeError: res.json is not a function in express.router" indicates that

I encountered the following error message and I'm not sure how to resolve it: TypeError: res.json is not a function I have reviewed the express documentation but couldn't find any syntax errors or issues. Here is my code: index.js import expr ...

What is the optimal strategy for incorporating both useLazyQuery and useQuery within the Apollo-client based on specific conditions?

In the navigation menu, I have options for "foods" and "cakes." The Foods page displays a list of all food items url: /foods When the user clicks on cakes, they are redirected to /foods?food=cakes, which is essentially the same page as the foods above. ...

Troubleshooting: issues with jQuery AJAX POST functionality

My goal is to perform an AJAX operation, and while the call seems to be functioning correctly, I am encountering an issue where the response I receive is just an empty string. Surprisingly, there are no errors being displayed in the console - only an empty ...

Using .float-right and .float-left within a .row in bootstrap 4 does not achieve the desired result

When using Bootstrap 4, the float property may not work as expected inside a row. I am trying to have the right div appear on the left and the left div appear on the right, but in responsive view I want the right div to be displayed before the left div. ...

When attempting to log an AJAX/JSON request, the console.log statement is displaying 'undefined'

Being new to AJAX, I have encountered an issue that I believe others may have faced as well. Despite numerous attempts and extensive research, I am unable to find a solution to this error. I am confident that it is something simple. Any help would be gre ...

Issue with onClientClick not functioning properly when performing a jQuery function call

How can I make a jQuery form appear when an ASP.NET server-side button is clicked by the user? Currently, when I click on the button during runtime, the page reloads quickly without displaying the jQuery form. I am aiming to achieve a similar effect show ...

It is not possible to place the cursor before a non-contenteditable div within a contenteditable div

Here is the layout I am working with: <div contenteditable=true> /// <div contenteditable=false>not editable</div> /// </div> One problem I'm facing is that when the non-contenteditable div is the first element on a ...

Ellipsis malfunctioning in text overflow

It is known that the display type table-cell does not work with text-overflow ellipsis. However, this is where my issue lies. I am dealing with a file input control that appears like this: <div class="ui-select form-input" style="display:inline-block; ...

The unit test for displaying the modal with the ID 'modalId' returned an undefined value

Being a beginner in both unit testing and angularjs, I encountered an issue while trying to test if my modals are displaying correctly. > TypeError: undefined is not a constructor (evaluating '$('#modalId').modal('show')') ...

Adjust the size of icon passed as props in React

Below is the component I am working on: import ListItemButton from '@mui/material/ListItemButton'; import ListItemIcon from '@mui/material/ListItemIcon'; import Tooltip from '@mui/material/Tooltip'; const MenuItem = ({data, o ...

A helpful guide on using workbox to effectively cache all URLs that follow the /page/id pattern, where id is a

Looking at this code snippet from my nodejs server: router.get('/page/:id', async function (req, res, next) { var id = req.params.id; if ( typeof req.params.id === "number"){id = parseInt(id);} res.render('page.ejs' , { vara:a , va ...

Angular 10 is displaying a message indicating that a font has not been

I'm facing an error in my Angular project when trying to add a font to the SCSS file. How can I resolve this issue? style.scss: @import "~@angular/material/theming"; @include mat-core(); $PWP-primary: mat-palette($mat-indigo); $PWP-accent: ...

Troubles with setting up slash commands in discord.js v13

I am encountering an issue while trying to deploy a slash command. The error message DiscordAPIError[50035] is displayed, stating "Invalid Form Body guild_id[NUMBER_TYPE_COERCE]: Value \"undefined\" is not snowflake." const path = require('n ...

Ensure the beginning and ending times are accurate for newly added input fields using jQuery

I've included a JSFIDDLE link here for reference. The validation for start and end time kicks in when the 'Next' button is clicked, located on the same page. I'm looking to validate the start and end times for dynamically generated fiel ...