Is there a way to create a sunken shadow effect on just one side of an

Is it possible to make the shadow appear only on one side (Top) using CSS?

I've tried multiple solutions, but I always end up with a shadow on all sides.

This is what I have attempted:

.box-container{
  width:100%;
  height: 80px;
  padding:10px 10%;
  background-color: #f00;
}
.box-inner{
  width:80%;
  height: 100%;
  background-color: #ff0;
  box-shadow: inset 0 5px 5px rgba(0,0,0,0.5);
}
<div class="box-container">
<div class="box-inner"></div>
</div>

Answer №1

Here is a suggested code snippet for you to try out:

.container-1{
  width:80%;
  height: 60px;
  padding:10px 5%;
  background-color: #00f;
}
.inner-box{
  width:70%;
  height: 90%;
  background-color: #0ff;
  box-shadow: inset 0 -20px 20px -20px rgba(0,0,0,0.6);
}
<div class="container-1">
<div class="inner-box"></div>
</div>

Answer №2

Give this a shot:

box-shadow: inset 0 7px 9px -7px rgba(0,0,0,0.7);
applied specifically to the top

I believe this could be beneficial for you...

Answer №3

experience the power of this

.container-box{
  width:100%;
  height: 80px;
  padding:10px 10%;
  background-color: #f00;
}
.inner-box{
  width:80%;
  height: 100%;
  background-color: #ff0;
  -moz-box-shadow:    inset  0  8px 8px -8px rgba(0,0,0,0.8);
  -webkit-box-shadow: inset  0  8px 8px -8px rgba(0,0,0,0.8);
  box-shadow:        inset  0  8px 8px -8px rgba(0,0,0,0.8);
}
<div class="container-box">
<div class="inner-box"></div>
</div>

Check out for a deeper dive into box shadows.

I hope this fulfilled your needs!

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 process for connecting controls to Canvas sprites?

Any input is EXTREMELY helpful! To put it shortly, I'm in need of assistance with utilizing HTML5/CSS3 buttons to manage sprite animations on my canvas. These buttons are responsible for controlling the direction and speed of the sprites independentl ...

When the @gridGutterWidth(s) is set to 0px for a flush grid in Bootstrap, the navbar's 'a.brand' breaks onto its

Big shoutout to the amazing StackOverflow community for helping me eradicate countless bugs before they even surfaced. Your crowd sourcing powers are truly magical. I'm in the process of building a website using the Wordpress Roots theme, which is ba ...

What is the alternative way to display two tables side by side in HTML without relying on the "style" tag?

For my project, I have created two tables and I am looking for a way to display them side by side without relying on inline styles. Does anyone have any suggestions on how to achieve this? ...

Create a new div element in your HTML structure that is not currently defined in your Sass/CSS

Currently, I am developing a React Component that includes a DatePicker feature using PrimeReact's Calendar component. I have a specific requirement to display an arrow on top of the datepicker when it pops up. You can view the desired layout in the ...

My goal is to develop a table that is both able to be resized and easily repositioned

I've been working on a project to develop an interactive table that can be manipulated, resized, and repositioned within a canvas. The code snippet below shows my attempt at creating this table on the canvas: var canvas = document.getElementById("dra ...

Firefox experiencing problem with retrieving video.duration in HTML5

I am currently working on developing a unique video player from scratch. <video preload="metadata" id="videoPlayer" style="width: 640px; height: 360px;"> </video> <script type="text/javascript"> var v = ""; var myV ...

How can I use jQuery to switch the positions of two <div> elements in HTML based on the selection of a dropdown value?

I need to switch the display positions of two <div> containers based on a dropdown value change. Can this be accomplished using jQuery? Here are the two div containers whose display positions need to be interchanged: <div id="first"><p> ...

Dompdf is outputting the HTML Bootstrap code as col-sm-x instead of col-lg-x

Currently, I am utilizing Dompdf in my PHP project to generate PDF reports. However, I have encountered an issue where the HTML bootstrap code does not render as expected on the PDF document. Specifically, when viewing the grid on a smaller device, it coll ...

difficulty with ajax to exhibit the information from a basic document

I'm trying to achieve a simple task using ajax. On my Mac, I have a folder containing 2 documents: index.html and text.txt. index.html : <p> <input type="button" onclick="loadDoc()" value="CLICK" /> </p> <p id="fileContent"&g ...

The Mat table is not updating on its own

I am facing an issue in my Angular application where a component fetches a hardcoded list from a service and subscribes to an observable to update the list dynamically. The problem arises when I delete an element from the list, as it does not automaticall ...

Tips for applying a class to two elements when a checkbox is clicked and avoiding duplicated URL strings

Issue with Checkbox Selection In my project, I have implemented two tabbed containers for grid and list view. Each container contains multiple elements called info boxes with checkbox inputs. Whenever a checkbox is checked, the background color of the res ...

What is the best way to adjust the volume vertically?

I successfully transformed my volume slider from horizontal to vertical using CSS. However, the functionality of the volume slider still behaves as if it were horizontal. In other words, I have to click horizontally to adjust the volume instead of vertical ...

Tips for ensuring that a span element outside of an anchor functions as though it were inside of it

I'm facing a challenge with my markup that I need help solving. Here is the scenario: I have provided a link within an anchor tag, but I want users to be able to click anywhere on the li tag in order to be redirected to the link specified in the ancho ...

How can I use jQuery to dynamically add and remove input values?

I am having trouble with saving and deleting values in a table row. I have an input field and an add button. When I click on the add button, I want the input value to be saved in a table row with a delete button next to it. I need to be able to delete indi ...

Add opening and closing HTML tags to enclose an already existing HTML structure

Is there a way to dynamically wrap the p tag inside a div with the class .description-wrapper using JavaScript or jQuery? This is the current html structure: <div class="coursePrerequisites"> <p> Lorem ipsum.. </p> </ ...

Is there a way to detect duplicate usernames in a form without actually submitting the form, and then automatically focus on the username field if a duplicate is

I need help with a user registration form that I am creating. I want the form to automatically search for an existing username as soon as the user starts typing in the username field. If the username already exists, I want the field to receive focus. In my ...

What is the best way to display DT elements next to each other?

Here is a link to the code snippet: http://jsfiddle.net/ZcdkT/1/ The code renders as: DT-nameA DD-definitionA 1 DT-nameB DD-definitionB 1 DD-definitionB 2 I would like it to be formatted like this: DT-nameA DT-nameB DD-definitionA 1 ...

Tips for positioning text alongside ICONS using CSS

Is there a way to align the text in the second row with the text in the first line? Here is the URL for my website: https://stgbusiness.wpengine.com/ And here is the code: <img src="https://stgbusiness.wpengine.com/wp-content/uploads/2021/10/modu ...

Determine if a paragraph contains a specified value using jQuery

I need to only select the checkboxes that do not have a value in the paragraph. Some mistake seems to be causing all the checkboxes to be marked when I click the button (Value > 0). Can you spot where I went wrong? $("input[id*='btnValue']" ...

"Discover the simplicity of customizing Bootstrap 5 with an easy-to-use online tool

When I was using Bootstrap 3, there was a convenient tool that allowed me to customize which features I wanted in the minified CSS/JS files to improve loading time. Now, as I delve into the documentation for Bootstrap 5, I find myself struggling to unders ...