What is the best way to implement a 'box-shadow-right' that stops at the border?

How can I achieve a seamless shadow effect at the border-right of a small div that matches the shadow of a larger div, without cutting off at the border-bottom of the small div or the border-top of the large div? I am unable to use Z-index due to the complexity of my website, and Spread is not an option as it detracts from the 3D appearance.
Here is the HTML:

 <!DOCTYPE html>
<html>
   <head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div id="small"></div>
<div id="large"></div>
</body>
</html>

And the corresponding CSS:

#small {
border: 1px solid black;
width: 200px;
height: 50px;
}
#large {
width: 300px;
border: 1px solid black;
height: 100px;
-webkit-box-shadow: 7px 7px 5px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow:    7px 7px 5px 0px rgba(50, 50, 50, 0.75);
box-shadow:         7px 7px 5px 0px rgba(50, 50, 50, 0.75);
} 

Here is a link to the JS Bin for reference: http://jsbin.com/vijujaweja/edit

I realize the format of my question may be a bit unclear, but I appreciate your understanding.

Answer №1

Have you considered adding background colors to the div elements?

Check out the code here

#small {
  border: 2px solid black;
  width: 250px;
  height: 60px;
  background-color:#f2f2f2;
}
#large {
  width: 350px;
  border: 2px solid black;
  height: 120px;
  background-color:#f2f2f2;
}
.dropshadow {
  -webkit-box-shadow: 10px 10px 8px 0px rgba(50, 50, 50, 0.75);
  -moz-box-shadow: 10px 10px 8px 0px rgba(50, 50, 50, 0.75);
  box-shadow: 10px 10px 8px 0px rgba(50, 50, 50, 0.75);
}

Answer №2

Is this the format you prefer? http://jsbin.com/xohomaraqe/1/edit I have made some updates to the code.

Revised

Now this should function as intended

#small{
   -webkit-box-shadow: 9px 1px 3px -1px rgba(50, 50, 50, 0.75);
}

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

Aligning an image vertically within a division

I am currently working on aligning images vertically within an image rotator (SlideDeck). At the moment, all the images are aligned at the top but I need them to be centered. The heights of the images vary. I have tried several methods, including absolute ...

Getting the JavaScript file name within another JavaScript file - a simple guide

Imagine having an HTML file that references two external JavaScript files. One of these JavaScript files contains errors (likely compilation errors), while the other file includes an onerror method without any issues. When you open the HTML file in a brows ...

Unable to center div container with margin set to auto

I'm struggling to center my container on the website. My goal is to have it centered and take up about 80% of the page so I can incorporate an image slider and text inside. Using margin: 0 auto doesn't seem to be achieving what I want. The backgr ...

There is a space separating the slider image and the navigation bar

Having a small space between the slider image and the navigation bar is causing some issues. I've tried various solutions like minifying the code, adjusting margins, and setting line heights to zero but nothing seems to be working. One question I have ...

Sentence following the original passage

I want to achieve a similar look as the example below: Here is what I have done so far: h2:after { content: ""; display: inline-block; height: 0.5em; vertical-align: bottom; width: 48px; margin-right: -100%; margin-left: 10px; border-bo ...

VSCode - when indenting, spaces are added around strings

Currently, I am utilizing Vue 3 along with Prettier in VS Code. One issue I am encountering is that when a string is on its own line, it is formatted correctly to my liking. However, the problem arises when my browser in Dev Tools renders strings with extr ...

Instructions for instructing Codeception to finalize the selection from a dropdown list without the need to click on a submit button

I am facing an issue where I am able to select an element from a drop down list in codeception, but it is not being displayed as selected in the box. I believe the select operation is not completing properly. Since there is no submit button available, I at ...

Is there a way for me to generate a tab that shows content when hovered over?

Is it possible to create a tab that displays a vertical list of redirections when the mouse hovers over it, and hides when the mouse is moved away? This seems like a challenging task. Can someone guide me on how to achieve this, especially if it involves ...

Creating a responsive canvas and image container in fabric.js involves adjusting the layout and size of the

I am working with fabric.js and canvas to dynamically add an image from a URL. I would like to make the canvas responsive based on the resolution. How can this be achieved? Here is my current code: <canvas id="panel" width="700" height="350"></ ...

Conceal a list of items within a div that has a particular class

This is a sample of my HTML code: <div class="row"> <div class="col-md-12"> <div class="scrollbox list"> <ul class="list-unstyled"> <li id="articulate.flute">articulate flut ...

How can one gain access to a specifically generated element?

In my task of dynamically generating multiple elements, I am facing an issue related to accessing specific ones. To illustrate this problem as simply as possible, I have provided the following code: $(document).ready(function() { var num1 = 0; v ...

Selecting the incorrect label while hovering over a checkbox

I am using Bootstrap and encountering an issue with displaying checkboxes after clicking on an accordion element. While the first checkbox is displayed correctly, the checkboxes inside the accordion do not appear as expected. It is confusing to me why thi ...

triangle shape filled with a gradient that transitions between two colors

I have two triangles displayed at the bottom of my page - one on the left and one on the right. The right triangle is currently transparent but I want to add a gradient effect to it. For the triangle-bottom-right, I'd like the gradient to go from rgb ...

Steps to incorporate a personalized design onto a card element within Material UI

As a JavaScript developer, I was tasked by my brother to create a simple webpage for his business. Admittedly, frontend design is not my strongest suit so I decided to utilize Material UI and added some CSS to paste everything together. Right now, I am wo ...

Using CSS or Javascript, you can eliminate the (textnode) from Github Gist lists

My goal is to extract the username and / values from a series of gists on Github Gists. The challenge lies in the fact that there are no identifiable classes or IDs for the / value. https://i.stack.imgur.com/9d0kl.png Below is the HTML snippet with a lin ...

Show content when box is ticked

I am looking to display a row of text when a checkbox is checked, but I am finding it challenging as a beginner in this. Despite trying to understand other answers, I still struggle with the process. Here is what I have attempted so far: function RiskPl ...

When the mobile navigation bar is tapped, it remains open instead of closing

The persistent challenge of the mobile navbar failing to close upon clicking an item continues to baffle. Numerous attempts from Stack Overflow and even tweaks recommended by ChatGPT have been futile in resolving this issue. Despite trying alternative me ...

How to dynamically add table rows and cells with JavaScript using a single selection input

I am working on a project that involves a selection input with around 5 options. Additionally, there is an empty table that follows this format: <table> <tr> <td>X (for deletion)</td> <td>Option name</td> ...

Is there a way to fill an HTML text box with data retrieved from a session or managed on the server side using C# and HTML?

I have some textbox values on an aspx page that I pass to the next page using sessions. Now, I want to display these values in an HTML textbox. How can I achieve this? The values I have are server-side, while the HTML text box value is client-side (this is ...

Encountered a MySQL error while attempting to insert an image into the database

I have a task to work on a website where users can upload product images that will be stored in a MySQL database. The code for my HTML form is: <FORM action="testimage1.php" ENCTYPE="multipart/form-data" method="post"> <div st ...