Can CSS3 be utilized to produce a shadow effect similar to this?

Although I have my doubts, is there any possibility to achieve such shadows in CSS3? Has anyone experimented with this and uncovered a solution?

I am faced with a layout where the sidebar, of limited height, is positioned on the right while the content extends longer toward the left. The shadow should emerge gradually at the beginning and fade away towards the end. Is it feasible to create this effect purely using procedural methods without utilizing any raster images?

Answer №1

One method to create radial gradients is demonstrated below:

#leftshadow
{
    margin-left: 10px;
    height: 200px;
    width: 20px;
    border-left:1px solid #ebebeb;
    border-left:1px solid rgba(0,0,0,0.4);
    background:-webkit-gradient(linear,left top,right top,from(rgba(0,0,0,.3)),to(rgba(0,0,0,0)));
    -webkit-mask-box-image:-webkit-gradient(linear,left top,right bottom,color-stop(0.0,rgba(0,0,0,0)),color-stop(0.5,rgba(0,0,0,.8)),color-stop(1.0,rgba(0,0,0,0)));
    background-image:-moz-radial-gradient(left,ellipse farthest-side,rgba(0,0,0,.3),rgba(0,0,0,0));
}​

Access the jsFiddle demonstration here

An alternate variation is available here


The original solution provided was as follows:

If you want a simpler inset shadow effect, you can utilize this code snippet:

#leftshadow
{
    -webkit-box-shadow: inset 5px 0px 5px -2px rgba(0,0,0,0.4);
    -moz-box-shadow: inset 5px 0px 5px -2px rgba(0,0,0,0.4);
    box-shadow: inset inset 5px 0px 5px -2px rgba(0,0,0,0.4);
}​

Preview the corresponding jsFiddle here

Answer №2

One neat trick that can be utilized is by layering a secondary div with a white shadow effect:

Check out this demo for reference

Although it may not be flawless, you have the flexibility to adjust it according to your requirements.

Here's the basic HTML structure used for achieving this effect:

<div id="main">
<div id="cheat"></div>

</div>​

Below is the CSS styling for creating the desired shadow effect:

#main
{
    width: 100px;
    height: 300px;
    -webkit-box-shadow: inset 10px 0px 5px -2px #888 ;
    position: relative;
}

#cheat {
    width: 300px;
    height: 300px;
    -webkit-box-shadow: inset 10px 0px 5px -50px white ;
    position: absolute;
    left: -100px;
}

Please keep in mind that while you could experiment with multiple box shadows, its compatibility might vary across different browsers.

Answer №3

I managed to create a solution that closely resembles the desired outcome:

div {
  width: 300px;
  height: 600px;
  border: solid 1px;
  box-shadow:
    inset 0px 10px 10px #fff,  
    inset 0px -10px 10px #fff,
    inset 10px 0px 20px rgba(0, 0, 0, .3);
}

Try it out here: Tinkerbin

Answer №4

give this a shot http://jsfiddle.net/7PRFg/1/

span{
    height:150px;
    width:80px;
    background-color:blue;
    border:1px solid #eaeaea;
    box-shadow:5px 0px 15px -5px rgba(0,0,0,0.3) inset;
}

Answer №5

.container {
    z-index: 100;
    border: none;
    padding: 0 0 0 10px;    
    background-image: url("images/topShadow"), url('images/bottomShadow'), url('images/shadow');
    background-position: 0 top, left top, 0 bottom;
    background-repeat: no-repeat, repeat-x, no-repeat;
}

While this code is untested, it should work with some adjustments that can be made later on. The concept here involves using three separate images for the top, middle, and bottom sections of a box. By utilizing CSS3 multiple background images, you can create a left border effect by adding padding to the left side of the container. The order in which the images are specified is crucial as it determines their layering - the first image listed will appear on top of the others. Essentially, the order acts as a form of z-index for the background images.

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

Positioning elements as absolute and setting the left value to 0 will prevent the ul from being

I've been working on my HTML and trying to position my dropdown menu to the left of the screen. I've used inline styling with absolute positioning and left:0, but for some reason, it's not working. Can someone please help me figure this out ...

Embed a javascript tag to print a PDF document

I have been struggling with printing a PDF file using JavaScript. I attempted to use the embed trick suggested in this Silent print a embedded PDF but unfortunately, the print function remained undefined. Then, I tried another approach using an Iframe and ...

tips for passing value to the date field using proctractor

This is the HTML code I am working with: <input id="filter-datepicker" type="daterange" ranges="ranges" class="form-control date-picker" placeholder="Select Date Range" name="sensorDetails.date" ng-model="myDateRange" ranges="ranges" requi ...

Prevent a div from scrolling once it reaches the end of its content, while allowing the other div to continue

I am trying to make the col-md-4 column stop scrolling once it reaches the end of the content, similar to the right sidebar on Facebook. I have attempted using jQuery to add a fixed position when it reaches the bottom, but it is not working as expected. Th ...

At what point in the lifecycle of my component am I able to begin using this.$refs?

Exploring ways to integrate HTML5 audio events while initializing a Vue.js component that consists of a single file: <template> <audio ref="player" v-bind:src="activeStationUrl" v-if="activeStationUrl" controls autoplay></audio> < ...

Issue with Jquery function not executing on second attempt

/** Creates a table of iTunes data in HTML format **/ var appendValues = function(songArray) { songArray.each(function() { var title = $(this).find("im\\:name").eq(0).text(); var songImage = $(this).find("im\\:image").eq(0).text(); var ...

Customize Swiper js: How to adjust the Gap Size Between Slides using rem, em, or %?

Is there a way to adjust the spacing between slides in Swiper js using relative units such as 2rem? The entire page is designed with relative units. All measurements are set in rem, which adjusts based on the viewport size for optimal adaptability. For i ...

Animate the transition of the previous element moving downward while simultaneously introducing a new element at the top

I currently have a hidden element called "new element" that is controlled by v-if. My goal is to create a button labeled "display" that, upon clicking, will reveal the new element on top after sliding down an old element. How can I achieve this using CSS ...

Inserting a PHP variable ($username) into a form field

<form method="POST"> <h1>Contact Us</h1> <span><h2 class="required">*Required</h2></span> <div class="input-group"> <label class="sr-only">First Name</label> <input class="text" ...

Using React.js to dynamically change a CSS class depending on a certain condition

I am trying to assign a CSS class to a div based on a specific condition. The issue I am facing is that it always takes the last condition. Below is the code snippet: When I run the code, I receive logos.length as 3 <div className= "${ (this.state. ...

Issues arising from data representation on the user interface using AngularJS

Below is a JSON sample containing 2 objects that I am fetching: [{"project_id":"538","proyecto":"Caja","tarea":"DEF","fecha_termino":"00-00-00","estado":"Vencido","nombre_completo":"Christiano Ronaldo","alerta":"-Analista responsable: Lionel Messi.; &bsol ...

What methods are available for drawing on an HTML canvas using a mouse?

I am facing two challenges: how can I create rectangles using the mouse on an HTML canvas, and why is my timer not visible? Despite trying various code snippets, nothing seems to be working. Grateful for any help! HTML: <!DOCTYPE html> <html lan ...

Trouble encountered when attempting to employ mysqli_num_rows() within a write context due to inability to use function return value

Recently, I've been working on a project involving the addition of users to my database. One particular issue I encountered was attempting to check if a login is already in use. My plan was for PHP to add the user to the database if the login is avail ...

Unable to get Flexbox 'align-items: center' to work on Chrome beta browser

In the scenario presented below, all modern web browsers that support flexbox display the page as intended. Check out the jsfiddle example here. Thanks to the align-items: center; property, the three colored blocks are evenly spaced within the section el ...

Troubles arising from the lack of character encoding declaration in the HTML document

Recently, I created a form for users to fill out that has the ability to validate email entries. When a user submits the form: If the email is incorrectly formatted, an error message will be displayed. If the email is correctly formatted, a confirmation ...

Centrally aligning text in lists with bullet icons

Struggling to align the text in a list with the SVG icons of the bullets? I've tried numerous solutions found online, but setting vertical-align: middle doesn't seem to work. Additionally, applying display: flex; align-items: center; to the pare ...

Rectangular divs with percentage-based width and height calculation are not displaying properly

I am currently experiencing an issue where two rectangular divs, which are supposed to be calculated using percentage based width and height, are not appearing on my webpage. Here is the HTML code I have in the body section: <div class="brd"></di ...

Is it possible to align the last item in a MUI stack to the bottom?

https://i.stack.imgur.com/IsutM.png Currently, I am working on a modal component using MUI's Grid. My goal is to position the Button at the bottom of the modal. const styles = { modalBox: { position: 'absolute', top: &ap ...

Make sure the division remains fixed even when the window is resized

Having a fixed position and bottom set to 0, I want my div to display at the bottom of the window. The issue arises when the window is resized, causing the div to move up and into other elements. For instance, when opening the console box in Chrome, the f ...

Choose the selectize item to always move to the front

Hey there, I'm currently using the selectize plugin to incorporate tags into my website. Everything is working well, except for the issue of the drop-down item being obscured by some of my other divs. I'm looking to have them function more like ...