Conceal the parent div from its sibling within the same parent container

My goal is to conceal a parent component from its child element. I attempted to achieve this by using the parent component as a background while adding additional backgrounds to the child elements for overriding purposes. However, this method did not work well for me due to certain frontend issues.

Is there a way to hide child1 (when it is set to absolute positioning, as that is the only layout that functions correctly on my frontend for design reasons) from child3 when it becomes visible on child2?

Thank you in advance for any insights or suggestions.

<main className="mainbg">
    <div className="child1">
              a component along the page. from top to bottom. see css.
    </div>
    {/*/ <Awesomeslider> /*/}
    <div className="child2">
         firstslide
    </div>
    <div className="child3">
        rightslide
    </div>
    {/*/ <Awesomeslider/> /*/}
</main>

//Slider with React.js = awesomeslider
.mainbg {
    width: 100vw;
    height: fit-content;
    display: block;
    background: linear-gradient(/*/ some gradient along the page including sliders /*/);
}
.child1 {
    position: absolute;
    top: 0;
    width: 50vw;              /*/ will be setted as it will be fit along full page from main to child2, but it must be hidden in child3 /*/
    margin: auto;
}
.child2 {
    width: 100vw;
    height: fit-content;            /*/ child1 will be visible here /*/
}

.child3 {
    width: 100vw;
    height: fit-content;              /*/ child1 won't be visible here /*/
}
<div id="root"><div/>

Additional Draft:

Answer №1

To hide certain elements, simply include z-index: -1. Conversely, to display a specific element, apply z-index: 1.

Keep in mind that the z-index property will only take effect if the element also has position: ANY_POSITION specified.

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

Obtaining an identification using JQuery for content that is constantly changing

I am currently developing dynamic content tabs using PHP, with one of the objects being a datatable within the tab. In order to define the ID via PHP, I use the following code: PHP: echo '<table class="table table-striped table-bordered table-hov ...

Guide on incorporating a YouTube iframe in React with Typescript

It appears that Typescript is posing some challenges for me in this scenario. Here's the code snippet I am trying to include: <iframe width="560" height="315" src="https://www.youtube.com/embed/BLAH?showinfo=0" frameBorder="0" ...

What is the best way to convert the javascript code into clojurescript?

Looking to utilize capacitor/app in order to determine the state (background or active) of my iOS app. My project is built on Clojurescript, so I need to convert the following javascript code into a clojurescript equivalent. Javascript import { App } fro ...

What is the best way to incorporate Ajax into a Rails application?

Check out the Webpage Design I am currently working on a Todo List that includes various Todo Items. Each incomplete task has a button called "Mark Item as Done" next to it, which triggers the button_to method when clicked. I am facing challenges in imple ...

Alter the background color of the text input when it is selected for exit

How can I adjust the input field color when text is selected? I'm looking to get rid of the dark grey box highlighting. (Check out the image below) https://i.sstatic.net/OgWaz.gif <div id="ember1102" class="ember-view"> <i class="fa fa ...

Split an array of simple data types in JavaScript into separate sections

Is there a way to divide an unordered array of primitive types into specific segments like this: var array = [102,103,104,201,203,204,303,301,302,405,406,408,101]; => newArray = [[101,102,103,104],[201,203,204],[303,301,302],[405,406,408]] The divi ...

Can you pass a custom argument to the callback function in setState()?

Is it possible to pass an argument to the setState function in React? removeTodo(index) { this.setState((prevState, props) => ({ todoList: [...prevState.todoList.slice(0, index), ...prevState.todoList.slice(index + 1)] })) } Or is work ...

What is the best way to retrieve the state from within a class method?

I'm having trouble accessing the redux state within this function in order to call Translator.init(data) whenever needed. Despite my efforts, I can't seem to access the state as expected. Since I'm more familiar with functional components th ...

Angular8 Chart.js customizes the Y axis tick labels

Is there a way to dynamically adjust the Y-axis ticks in a chart.js graph? I attempted to modify them using the following commands: this.chartOptions.scales.yAxes[0].ticks.min = 10; this.chartOptions.scales.yAxes[0].ticks.max = 18; ...

I am looking to sort through the data based on the courseCode, but I can't seem to find a way to do it

Here is the JSON data after converting it with res.json() I attempted to filter it based on course code, let's say the code is: 301. I am confused about how to achieve this using JavaScript because of the nested structure. Here is the code snippet I ...

What is causing the TypeError when trying to set a property on undefined in AngularJS?

I've taken on the challenge of building a microblog app to learn more about angularJS. One thing that's really getting me is trying to understand the differences between service, factory, and provider. After some research, I decided to go with s ...

What are the best techniques for resizing a Text Field with media queries?

The contact form is responsive and functioning correctly for the textarea field, but there are issues with the input type=text fields on smaller screens. I attempted to address this by incorporating media queries. Below is my code: <!doctype html> ...

Transfer the file image stored in a MySQL database to an excel spreadsheet

Having an issue with capturing image data input from a PHP and HTML database to Excel. I am trying to display the images in a specific size within an Excel file. Below is the PHP code used to create the table: <?php header("Content-type: application/o ...

What is the best way to align an image underneath text?

I'm currently working on this design concept: https://i.stack.imgur.com/wJm0t.png Below the title, there is a particle image with half square images positioned on the top right and bottom left corners. My goal is to center the particle image below th ...

Using React Native to pull data in my app from mySQL database

In my coding journey, I encountered a local database managed through myPHPadmin, and implemented the following code snippet: // Here is a glimpse into the routes.js file! const express = require('express'); const bodyParser = require('body- ...

Encountering difficulties in accessing files displayed by serve-index in Express

My Node.js server using Express seems to be working fine for displaying directory contents, but I'm running into an issue when trying to access individual files. After clicking on a file listed in the directory, I keep getting an error message that sa ...

transforming an array into JSON structure using node.js

Hello, I have a list of data that I need to convert into JSON format. Here is an example of how I want the data to look: [ { "slideName": "s0", "imageUrl": "https://s3.amazonaws.com/lifestyle345/testing/slides/cbaa5e650152a0332b494f0074985 ...

The height of the textarea is too excessive

Just a quick question - in my HTML, I have a simple textarea nested within the body tags. Within my JavaScript, I am using jQuery to ensure that the body element is dynamically resized to match the height of the window: $(function() { $("body").heigh ...

How to convert an array of keys and an array of values into an array of objects using JavaScript

My question is similar to the one found here: Merging keys array and values array into an object using JavaScript However, I am unable to find a solution for my specific scenario. If I have these two arrays: const keys = ['x', 'y', &ap ...

Can React be hosted on a Node server?

As a beginner in back-end coding, I am struggling to grasp the concept of a "fullstack" app. Can someone explain what it actually looks like? Is it: An application with a Node-Express server serving index.html, which includes <script src="main ...