The issue with the background attachment CSS property is that it does not display properly when overlapping with other HTML

I'm currently trying to understand the background-attachment CSS property, but I'm facing an issue where it doesn't display over textareas or images. Can someone help?

This is the HTML code I am using:

<div class="scrollbox">
    <ul>
        <li>Ah! Scroll down below!</li>
        <li>
            <textarea rows="6" cols="50"></textarea>
        </li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
        <li>7</li>
        <li>8</li>
        <li>9</li>
        <li>10</li>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>4</li>
        <li>5</li>
        <li>6</li>
        <li>7</li>
        <li>8</li>
        <li>9</li>
        <li>10</li>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <li>The end!</li>
        <li>No shadow here.</li>
    </ul>
</div>

Here is the CSS code I have written:

.scrollbox {
    overflow: auto;
    width: 500px;
    max-height: 500px;
    margin: 50px auto;

    background:
        /* Shadow covers */
        linear-gradient(white 30%, rgba(255,255,255,0)),
        linear-gradient(rgba(255,255,255,0), white 70%) 0 100%,

        /* Shadows */
        radial-gradient(50% 0, farthest-side, rgba(0,0,0,.2), rgba(0,0,0,0)),
        radial-gradient(50% 100%,farthest-side, rgba(0,0,0,.2), rgba(0,0,0,0)) 0 100%;
    background:
        /* Shadow covers */
        linear-gradient(white 30%, rgba(255,255,255,0)),
        linear-gradient(rgba(255,255,255,0), white 70%) 0 100%,

        /* Shadows */
        radial-gradient(farthest-side at 50% 0, rgba(0,0,0,.2), rgba(0,0,0,0)),
        radial-gradient(farthest-side at 50% 100%, rgba(0,0,0,.2), rgba(0,0,0,0)) 0 100%;
    background-repeat: no-repeat;
    background-color: white;
    background-size: 100% 40px, 100% 40px, 100% 14px, 100% 14px;

    /* Opera doesn't support this in the shorthand */
    background-attachment: local, local, scroll, scroll;
}

Answer №1

The shadow doesn't actually float above the contents within the div because it's a background image. It only appears that way due to the matching colors with the text. Changing the text color would reveal that the text is actually on top of the shadow.

Think of div.scrollbox as a physical box and the textarea as a smaller box inside of it. The smaller box obstructs the view of anything drawn beneath it on the larger box's surface.

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

Synchronize PHP jQuery BS-Calendar Ajax for a seamless integration of a jQuery calendar with AJAX button click functionality on document

I'm currently working on integrating a calendar into my project. You can find the calendar I'm referring to at this link: The issue I'm facing is that I need to use the same calendar with the IDs #datetimepicker8 and #datetimepicker9 five t ...

Filtering stop words in Python through HTML parsing using Beautiful Soup

I have developed a program that extracts specific information from a website and stores it in a file. Currently, the program scans a webpage, identifies the correct HTML tag, and extracts the relevant content. Now, I aim to refine these "results." For ins ...

Collapse in Bootstrap without any Animation

How can I add animation to the Bootstrap Collapse feature on my website? I am using an icon from the Font Awesome library to trigger the collapse effect, but currently, it just pops up without any animation. What could be causing this issue? You can view ...

What is the best method to retrieve particular HTML lines (containing a flex container) with IronPython?

Utilizing IronPython 2.7.9.0 in Grasshopper and Rhino, I am extracting data through web scraping from a specific widget on the following link: The code snippet being used is shown below import urllib import os web = urllib.urlopen(url) html = web.read() ...

The iPhone webview keyboard causes the layout to be pushed upward and remain elevated

While editing text fields, the native keyboard pops up and stays visible in the webview. It's almost like leaving the toilet seat up! Is there a way to return to the original scroll position after the native keyboard disappears? Perhaps an event that ...

Just a single page on my website extends beyond the footer's reach

Hey there, I'm pretty new to this whole HTML/CSS thing and need some help. I have a website called cme.horse and everything seems to be running smoothly except for the Home page (main/index page). The issue is that it scrolls past the footer, while al ...

Exploring different sections of the website

I am looking to create a seamless navigation experience between controls on a webpage. Below is an example code snippet that outlines the functionality where a user can click on any component and be directed to another controller. Sample code: const app ...

Unable to interact with anchor link

Currently, I am in the process of developing a new website that features a masonry/Pinterest style effect blog board. One issue I have encountered is that when hovering over a post, a button should appear to link through to the corresponding blog/single pa ...

How to concatenate a string variable to a hyperlink in a template file

Within my project, there is a file named registration_email.tpl that is passed as email_template in the bottle.template() function. This involves passing variables such as username, email_addr, role, creation_date, and registration_code. email_text = ...

Tips on redirecting a user to a specific page after they have made a selection without doing so immediately

I am a beginner in the world of coding. Currently, I am working on creating templates for an online software application. Users will have the option to select from different choices using radio buttons. However, I want to ensure that users are not redirect ...

Applying inline css transition style using a string distorts the original value. Strange

I have a CSS file that specifies a transition property as follows (vendor prefixes excluded for brevity): transition: opacity 1s; Now, I want to tweak the transition-delay property of each element using JavaScript to create a stagger effect. Here's h ...

Can one attach an HTML element to the bottom of another?

I have a question regarding formatting textual documents in HTML. I'm trying to find a way to display multiple pages within a single HTML document, specifically focusing on keeping the footer at the bottom of each page. My goal is to keep it simple, p ...

What methods are available for eliminating special characters from submitted data?

Looking for a way to eliminate special characters from incoming data. Regular Expressions could be an option, but wondering if there are other methods available. Any suggestions on how to remove these special characters? ...

Adding values with buttons to input ranges allows for easy manipulation and adjustment

Hey there! I need some help with manipulating a range slider using buttons. I added two buttons to decrease and increase the value, which you can check out in this FIDDLE. However, I am encountering an issue. When you click the "less" button multiple time ...

Is it possible to resume CSS animation when the page is first loaded?

I'm looking for a way to ensure that my CSS animations on the elements in my header.php file continue smoothly when navigating to different pages. For example, if I have a 200-second looped animation and navigate to the "about us" page 80 seconds int ...

Having trouble getting the Java applet to function properly on my HTML page

Currently, I am in the process of learning Java and came across an interesting concept that suggests I can also run my Java code in a browser using an applet. However, when I attempted to do so, an error message popped up prompting me to click for more det ...

Continuously spinning loading icon appears when submission button is triggered

We are currently experiencing some issues with our mobile forms. Our users utilize a mobile form to submit contact requests, but the problem arises when they hit 'submit' - the loading icon continues to spin even after the form has been successf ...

The animation of react-circular-progressbar is experiencing a slight delay of one second

I managed to create a circular progress bar with a timer and a button that adds +10 seconds to the timer. However, I'm facing a 1-second delay in the animation of the progress bar when clicking on the button. If anyone could assist me in resolving t ...

CSS and JavaScript Nav Menu Collapse (No Bootstrap)

I have written a navbar code using pure HTML/SASS, but I am facing a challenge in adding a collapse element to the navigation bar. Despite trying various solutions from Stack Overflow, I still haven't found one that works for me. Therefore, I am rea ...

unable to get highcharts to redraw and reflow properly

I am currently working on creating a dynamic page that can display between 1-4 graphs. These graphs need to be able to resize when added or removed from the page. However, I have encountered a major issue with resizing the graphs after resizing the contain ...