How can you apply a box-shadow inset effect to only the Left, Bottom, and Right sides, excluding the top?

I'm working with a box-shadow inset effect using CSS3:

box-shadow: inset 0 0 10px 0 rgba(255, 255, 255, 1);

The inset effect is applied to all sides of the box, but I only want it on the Left, Bottom, and Right sides - not the top. Is there a way to remove the effect from the top while keeping it on the other three sides?

Appreciate any help!

Answer №1

Here is the desired solution:

.bottom-right-left-shadow {
    box-shadow: 5px 0 5px -5px #CCC, 0 5px 5px -5px #CCC, -5px 0 5px -5px #CCC;
}

The first shadow represents the left side, the second one at the bottom, and finally the last one for the right side. This effect works really well with a border color of #CCC.

Answer №2

Although you cannot achieve that effect using only box-shadow, you can combine it with other techniques such as overflow: hidden. One approach is to extend the top shadow beyond the parent element and conceal that portion using overflow: hidden.

To see this concept in action, check out this demo: http://jsfiddle.net/EmmaSmith/Qwe4R/9/

Answer №3

Unfortunately, there isn't a straightforward CSS method for achieving this effect, but you can use the following workaround (although it's not a perfect solution):

    <div id="mydiv">
       <div class="workaround"></div>
    </div>

CSS:

   #mydiv { 
     background-color:#f00;
     height:100px;
     width:100px;
     box-shadow: inset 0 0 10px 0 rgba(255, 255, 255, 1);
     padding:0 2px;
  }
 #mydiv .workaround {
    background-color:#f00;
    width:100%;
    height:10px;
 }

You can check out the fiddle here: http://jsfiddle.net/bZF48/17/

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 is the method for adding a clickable link to an HTML tag in a shiny application?

Looking to jazz up my shiny app, I decided to add a footer using the HTML tag with fluidPage(): tags$footer(HTML(sprintf("For more information, visit www.website.com", align = "center", ...

Why is the JSfiddle tutorial not functioning properly in other environments, generating the error "Property 'clientHeight' cannot be read of null"?

I've been diving into a THREE.js tutorial to learn how to set up a basic scene and add animation keyframes triggered by scrolling. Everything worked smoothly in the fiddle, but when I tried to transfer it to my website, I encountered this persistent e ...

Drifting my dropdown menu bar through the digital sea

I'm having trouble with my navigation bar and I need help styling it. I want the navigation bar to have a dropdown menu when the user hovers over the top level of the navigation bar. The issue I am facing is that the second level of the navigation bar ...

Click and keystroke fusion

Greetings everyone, I've been attempting to integrate both click and keypress functionalities into my function, but unfortunately, nothing I've attempted so far has yielded any success. Here's the code snippet: function victoryMessage() { ...

Having trouble overriding the Slick carousel style in Angular 6?

Currently, I am utilizing Slick and jQuery for a carousel on my website. There seems to be an issue with the overriding style for the slick dots set in the component. Despite specifying the style in the component's CSS, the slick dots do not reflect t ...

Showing a DIV multiple times with an additional text field in HTML and JS

As someone new to development, I am facing a requirement where I need to create a form with a dynamic field that can be added or removed using buttons. When the user clicks on the Add button, another field should appear, and when they click on Remove, the ...

Having trouble getting CSS3 Keyframes to function properly?

Check out the following code snippet: .startanimation { height: 100px; width: 100px; background: yellow; -webkit-animation: animate 1s infinite; } @-webkit-keyframes animate { 100% { width: 300px; height: 300px; } ...

extracting data from checkbox to use in an angular function upon being selected

Currently, I am creating a list of checkboxes with distinct string values: heading, paragraph, list, table, visualtitle. I believe the current approach using (change)="onChange('heading', $event.target.checked) may not be the best way to han ...

The W3C Validator has found a discrepancy in the index.html file, specifically at the app-root location

While attempting to validate my HTML page, I encountered the following error: Error: Element app-root not allowed as child of element body in this context. (Suppressing further errors from this subtree.) From line 4347, column 7; to line 4347, column 16 ...

The photo is too big for the designated space

While trying to master CSS, I thought I had a handle on these images but it seems like I was wrong. I have a background image for a section and I've been adjusting the position to align with buttons, but now the whole page is expanding. I've exp ...

I am having trouble aligning these elements next to each other

Can anyone help me figure out why these elements won't center on the page? <ul id="contact"> <h1> Contact </h1> <p> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a2e6d0c7c3cfd1d6cdd5cac7c7ced1 ...

Incorrect x and y coordinates in the 'onclick' event

Hey there, I'm currently working on a simple prototype for an app. The concept is straightforward: there is a box, and when you click on it, it creates a square that changes color when clicked on. The issue I'm facing is that when I click on the ...

What is the best way to maximize the use of the space available until reaching a div with varying dimensions each time

I have a div on the left that displays a name, and it can vary in length. On the right, there is another div with buttons. The number of buttons may change, so I am unsure how many will be displayed. Is there a way to utilize only CSS to make sure the fi ...

Tips for inserting columns into a table using CSS and HTML

Having trouble working with columns in the tab div? It seems to work when it's pulled out of the tab div. Can anyone advise what I might be missing? For an example code, please visit: https://www.w3schools.com/code/tryit.asp?filename=FZJ3933552IJ Cu ...

Tips for preventing the automatic focus on the initial input field when displaying an HTML form within a JQuery dialog

I have come across similar inquiries on Stack Overflow, such as this particular one, albeit dated. Despite my efforts to search and follow provided links, it remains unclear whether a viable solution exists for this problem in current times. My main conce ...

Setting a variable for a JavaScript function to insert a video - a step-by-step guide

Here is a grid structure that I am working with: <div class="main"> <ul id="og-grid" class="og-grid"> <li> <a href="http://..." data-video="my-url" data-largesrc="images/1.jpg" data-title="Title" data-descript ...

Using HTML5 validation on a form along with a button that triggers a JavaScript function to send an email via PHP and display a modal upon

When I click the button on my website's form, a JS function is triggered to take the inputs from the form and send an email using PHP. After the email is sent, a modal popup appears thanking the user for contacting. Everything works perfectly until I ...

Retrieving the Image of an Amazon Product using ASIN

My goal is to locate the image URLs for Amazon products using only their ASIN. For instance: This link pertains to a product with the ASIN B07NVVQL66 in the United States. Clicking on it will display an image of the product http://images.amazon.com/imag ...

Mixing two images together as a background in Semantic-UI through crossfading

My goal is to create a crossfade effect between two images using JavaScript (for simplicity, I have used colors in the JSFiddle example). The images must be set as backgrounds of a div element. However, the behavior in the fiddle appears strange, as the d ...

Troubleshooting Vue.js rendering problems on Safari_BROWSER

I'm encountering a strange issue with my portfolio website, which is built using Vue and Laravel. The problem arises specifically in Safari - the project thumbnails don't display until the browser window is resized. Here's the relevant code ...