A <div> with relative positioning is inhibiting the visibility of absolutely positioned elements without any visible overlap

Recently, I encountered a strange issue on my webpage: Image of page The lines on the left side are supposed to be displayed behind or on top of the text box. However, when I increase their z-index, the lines extend all the way to the top of the page and get covered up by the div, despite its size being limited to that of the red box.

The problem lies within the html and body sections of my code. Removing them would disrupt the positioning of my navigation bar on the screen. To achieve the desired effect, please refer to the answer provided below.

        html, body {
    margin: 0;
    padding: 0;
    background-color: #e7e3d7;
  }

    .headerLarge {
        padding-top: 1.5rem;
        padding-bottom: 0px;
        font-size: 2rem;
        text-align: center;
        width: 50%;
        background-color: red;
      
      }
      
      .spine {
        position: absolute;
        z-index: -1;
        top: 0;
        bottom: -15px;
        left: 50%;
        border-left: 20px solid #cdcabf;
      }
    
      .page {
        position: absolute;
        top: 0;
        bottom: -15;
        z-index: -1;
        height: 100%;
        border-left: 4px solid #cdbfbf;
        
      }
 <span class="page" style="left: 0px; top: 0;"></span>
    <span class="page" style="left: 10px;"></span>
    <span class="page" style="left: 20px;"></span>
    
    <span class="spine"></span>
    
    <span class="page" style="right: 0px;"></span>
    <span class="page" style="right: 10px;"></span>
    <span class="page" style="right: 20px;"></span>
    
    <span class='headerLarge'>Doodle of the Day!</span>

Answer №1

Revised based on feedback:

.headerLarge {
  position: relative;
  padding-top: 1.5rem;
  padding-bottom: 0px;
  margin: 0 16px;
  font-size: 2rem;
  text-align: center;
  width: 50%;
  background-color: red;
}

.spine {
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: -15px;
  left: 50%;
  border-left: 20px solid #cdcabf;
}

.page {
  position: absolute;
  top: 0;
  bottom: -15;
  z-index: -1;
  height: 100%;
  border-left: 4px solid #cdbfbf;
}
<span class="page" style="left: 0px; top: 0;"></span>
<span class="page" style="left: 10px;"></span>
<span class="page" style="left: 20px;"></span>

<span class="spine"></span>

<span class="page" style="right: 0px;"></span>
<span class="page" style="right: 10px;"></span>
<span class="page" style="right: 20px;"></span>

<span class='headerLarge'>Sketch of the Day!</span>

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

a method for inserting a space after a certain character, with the exception of when that character is located at the start or end of a line

I've created a regular expression that can modify various patterns like: anything1 * anything2* anything3 anything1* anything2 * anything3 anything1 * anything2 * anything3 anything1*anything2 *anything3 anything1 * anything2 *anything3 anything1*any ...

Ways to prevent the "Site not secure" warning on an Express server with HTTPS configuration

In the process of creating an Express app, I decided to enable HTTPS for a secure connection. After obtaining a certificate from StartSSL.com and importing it into my server successfully, everything seemed set up correctly. However, an issue has arisen: h ...

Adjust the location of the scrollbar without affecting the alignment of the text

Currently, I'm experiencing a design issue with the textarea tag in my React project. The layout looks like this: https://i.stack.imgur.com/JG1sm.png I am looking to shift the scrollbar to the right without altering the text direction (rtl). Utilizin ...

Java code to extract and delete a section of a website on a webpage

@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ View view = inflater.inflate(R.layout.fwebview, container, false); webView = (WebView) view.findViewById(R.id.webView); String url = ge ...

Sending data from JavaScript to Jade templatesIs this alright?

Utilizing node.js, express, jade, and socket.io, I have successfully executed JavaScript code on the jade side. However, I am encountering difficulty in generating HTML output from the script block. Based on your feedback, I have updated my question to in ...

I receive an [object HTMLCollection] as the output

I am currently working on recreating a login page and I want it so that when the button is clicked, it displays the name you entered, but instead, it returns [object HTMLCollection]. My expectation was to have the name displayed as entered. var nombre ...

Adding choices to dropdown menu in AngularJS

As a beginner in AngularJs, I am struggling with appending options to select boxes created by javascript. Below is the code snippet that is causing the issue. var inputElements = $('<div><label style="float:left;">' + i + '</ ...

extracting data from a div while presenting a confirmation pop-up

I am attempting to extract information from a file on the following website. Specifically, I am trying to download an Excel sheet containing a complete directory of towns in TRIPURA, listed as the first item in grid format. Here is the code snippet I am ...

What is the best way to eliminate the unattractive white border surrounding dialog boxes?

Is there a way to remove the unsightly white outline around the UI Dialog? Check out this picture of the dialog I've tried various solutions I found on Google and Stack Overflow, such as: .ui-widget-content { border: none !important; outlin ...

Optimal Placement of CSS and index.html Files in ReactJS with Redux

Currently, my setup for the index.html file looks like this: <!doctype html> <html class="no-js" lang=""> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Pra ...

What is the best method for combining ajax and php to perform a redirect?

I'm facing an issue with redirecting users from the login page to their profile page. I'm using ajax to validate the form, but upon successful login, the profile page is displayed on top of the index page. How can I ensure that the redirection ha ...

Hmm, I seem to be encountering an error where res.sendStatus is not recognized as a function. What could be causing this

For the last few months, I have been immersed in Node.js/Express to create a REST Api. However, I've hit a roadblock with an async function in my controller.js file. The callback function is successfully receiving the client's request, but when i ...

Is your YQL JSON script failing to provide the expected output?

Here is a script that I have copied almost directly from this. Why is it that the code below does not seem to return anything? ajax.html: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html dir="lt ...

Exploring ways to extract key:value pairs from an encoded URL form using POST in express/node.js

I have a web form with 4 input fields. The form is set up as follows: <form action="/" method="post" onsubmit="alert('data submittet')"> It should default to x-www-form-urlencoded. The form functions correctly and I am able to submit my d ...

Arrange divs in a stack fashion

Currently, I have a table-styled three-column set of divs. I would like these columns to stack vertically on mobile devices. I think this can be achieved using the float method, but the titles and descriptions for each column are in separate rows (divs), ...

What are the methods for adjusting the height of one div in relation to another div?

How can I make the height of the first div equal to the dynamic height of the second div, when the second div contains a lot of dynamic data with an unpredictable height? <div style="width: 100%;"> <div class=& ...

Send error messages directly to the client side or retrieve status codes and messages

When responding to an AJAX request, encountering an app error like data validation failure can be tricky. How can we effectively communicate this to the user? 1. Returning a Status Code and Fetching Message with JS $.ajax(options).done(function(response) ...

Issues with Node JS app's handling of php mailer code

I've made a basic website using the Node JS framework and included a php mailer for handling the contact form. Unfortunately, I'm facing issues getting it to function properly. Could it be possible that there is an underlying problem with Node JS ...

What is the process for importing a class (.js file) into a .vue file?

I am facing an issue with my Vue application. I have created a class named `Authenticator` in the file `Authenticator.js`, and now I need to utilize its functions in my `Login.vue` file. Could someone guide me on how to properly export the `Authenticator` ...

What is the best approach to managing a Symfony form that contains TWO CollectionType child forms?

I have been referring to the Symfony guide here which explains how to generate and save a collection of associated entities within a form. Following the example provided in the guide, I have successfully implemented the functionality for adding and removi ...