Ways to create a cool visual effect by making the CSS shadow cover the content

This component may seem simple at first glance. The main div with the ID 'main' features a shadow property, while a second div with the ID 'sub' contains an array of interactive elements (buttons, dropdowns, etc., although the code example above has been simplified).

An issue arises when scrolling through the content, as the components within the content start to overlap the shadow effect. This results in certain areas where the shadow is not visible during scrolling.

The question now is: what approach should be taken to ensure that the shadow overlays the content smoothly?

return (
<div id='main' className="flex h-full shadow-[inset_0_10px_3px_red] ">
  <div
    id='sub'
    ref={ref}
    className="overflow-auto"
    style={{
      width: '100vw',
    }}
  >
    <div>Some text</div>
    // long list from <div>Some text</div>
    <div>Some text</div>
  </div>
</div>

);

Answer №1

To enhance the design, you might want to include an additional element inside the main container that features a shadow effect. This element can be positioned to stack on top of the other elements, creating an overlapping shadow effect.

<script src="https://cdn.tailwindcss.com/3.4.3"></script>

<div class="h-screen">
  <div id='main' class="flex h-full relative">
    <div class="absolute inset-0 shadow-[inset_0_10px_3px_red] pointer-events-none"></div>
    <div id='sub' class="overflow-auto" style="width: 100vw">
      <div class="h-[50vh] bg-blue-200">Some text</div>
      <div class="h-[50vh] bg-sky-200">Some text</div>
      <div class="h-[50vh] bg-cyan-200">Some text</div>
      <div class="h-[50vh] bg-teal-200">Some text</div>
      <div class="h-[50vh] bg-emerald-200">Some text</div>
    </div>
  </div>
</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

Using Fuse.js to simultaneously filter multiple lists

I am currently working with 3 lists that are being generated via an API. My goal is to filter all three lists simultaneously using Fuse js. Despite checking the documentation, I have not been able to find a solution for filtering multiple lists efficiently ...

The MUI DataGrid Pagination has been replaced due to an error: validateDOMNesting(...): <td> should not be nested within a <div>

I'm struggling with replacing the pagination in my DataGrid component from Material-UI. Every time I try, I encounter this console error: Warning: validateDOMNesting(...): <td> cannot appear as a child of <div> I've double-checked my ...

When I attempt to save in Visual Studio Code while using React, I encounter an issue

Whenever I try to save my code in Visual Studio Code while working with React, it causes things to break click here for image description ...

Default cursor for Internet Explorer: automatic

I have a container div that holds all of my website's content. I want this container to change the cursor to a pointer when clicked on, but I don't want the elements inside the container to inherit this cursor style: https://i.sstatic.net/8joJo. ...

Script for running a React app with Prettier and eslint in a looping fashion

My Create React App seems to be stuck in a compile loop, constantly repeating the process. Not only is this behavior unwanted, but it's also quite distracting. The constant compiling occurs when running the default npm run start command. I suspect t ...

Solving the issue of unnecessary white space when printing from Chrome

Whenever I print from Chrome, there seems to be extra space between lines in the middle of a paragraph! Here is an image showing the difference between print emulation and print preview This excess space is always in the same position on various pages an ...

Alter the CSS display based on the user's userAgent if they are using an iPhone and window.navigator.standalone is set to true

Looking to create a unique webAPP with different content displays based on how it is accessed. If the user opens the webAPP through their Safari browser Or if they open the webAPP from a webclip on their home screen The detection is functioning, as conf ...

Why isn't my element displaying on the screen?

Having recently started learning React, I've encountered a challenge that I've struggled with for quite some time - I can't seem to add a component inside the main app.js file. I initially set up my project using create-react-app. Here&apo ...

Tips for ensuring a button functions for only the specific element clicked, not all elements in a rendered list

I have a list that was generated from an array, with each element having a menu button that opens a modal specific to that element. However, I am facing an issue where clicking on the button for one index triggers the modal for all indexes instead of just ...

Creating a PDF document using HTML code

I am interested in creating a PDF file from an HTML code that includes the stylesheet rules using PHP. Currently, I am attempting to achieve this with the MPDF library. However, the generated PDF does not resemble the original HTML page. Many elements app ...

What is the best way to make an image clickable in Next.Js?

Is there a way to turn an image into a link in Next.Js? I have the Instagram logo that I want to use as a link to my Instagram page. I want it to open a new tab and redirect the user to my Instagram account when clicked. I would really appreciate any guid ...

Guide on updating a cell while editing another in MUI Data Grid v6

Currently, I am utilizing the MUI Data Grid v6 component and taking advantage of its built-in CRUD editing functionality. My setup includes multiple columns, all of which are editable. Upon selecting a new value in the "category" column with type singleSel ...

The Bootstrap CDN is malfunctioning and displaying errors in the console

I attempted to incorporate Bootstrap 4.5 using the CDN provided on their main website. However, after adding all the code lines to my project, I encountered numerous issues with my custom CSS and the Bootstrap carousel failing to function. Upon inspecting, ...

What is the best way to manage a situation where no link is returned to the "to" attribute of a Link component in React

Hey, I'm just starting out in programming and I have a question about handling the default case where no link is returned in the switch statement below: class ParentComponent extends React.PureComponent { get_link = () => { const item ...

What is the best way to retrieve all keys from an array or object within the selection in cxjs?

I have a List with Objects and I want the selection to carry the complete Objects. The current property selection method is not working for me. Is there a way to achieve this? ... records:bind="$myWindow.ObjectList" selection={{ ...

Is there a way to stack multiple divs on top of each other in my HTML login page?

Below is the HTML code for my form: <div style="display:block; margin:0 auto;"> <h2>Welcome</h2> </div> <div id="box"> <div id="box2"> <p id="pid"><b>Em ...

How can I effectively pass an array of objects to an interface in React with Typescript?

In my code, I have defined two interfaces as shown below: export interface TableBoxPropsHeader{ name: string, isIconOnly: boolean } export interface TableBoxProps<T> { headerNames: TableBoxPropsHeader[], // some stuff } I am currently fa ...

Discrepancies in media screen queries displaying on inspection tools compared to actual device

I've done some research online but I'm still struggling with this issue. Despite creating media screen queries and setting the viewport for iPhone 7 plus, the website does not display correctly on my device. When I inspect it using Chrome, every ...

The argument provided, which is of type 'any[]', cannot be assigned to a parameter of type 'A' because the property 'a' is missing in the 'any[]' type

As a newcomer to TypeScript, I am currently trying to grasp the workings of interfaces within a Class Method of a React Component. Despite creating a simple case for it, I am encountering errors similar to those described in this post. I would greatly app ...

What is the best way to add two hyperlinks within a single tab of a Bootstrap navigation menu?

I attempted to place two links in one tab, but I was unsuccessful. Here is my navbar code: <!DOCTYPE html> <html lang="eng"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scal ...