What is the best way to link the shadow of the box on a diagonal angle?

Can anyone help me create a unique box design? I've been using the box-shadow property and attempted to skew it, but the entire box ends up skewed.

https://i.sstatic.net/KJEtT.jpg I am trying to make the shadow on the box connect diagonally. However, I'm having trouble achieving this effect. Any suggestions?

#one {
  width: 400px;
  height: 200px;
  background-color: yellow;
  box-shadow: -10px 10px black;
  margin: 10% 0 10% 10%;
  transform: rotate(1.5deg) translateX(10px) translateY(15px) skewX(4deg) skewY(-4deg);
}
<body>
  <div id="one">
  </div>
</body>

Answer №1

To achieve this effect, you do not need to use any transform method. Simply utilize the box-shadow property.

Here is the syntax for box-shadow:

box-shadow: [horizontal offset] [vertical offset] [blur radius] [optional spread radius] [color];

You need to adjust the values for [horizontal offset] and [vertical offset].

Follow these steps:

Make sure to make the necessary adjustments until you achieve the desired result.

.box {
  width: 300px;
  margin: 50px auto;
  height: 100px;
  background: red;
  box-shadow: -1px 0px 0px #000, -0px 1px 0px #000, -2px 1px 0px #000, -1px 2px 0px #000, -3px 2px 0px #000, -2px 3px 0px #000, -4px 3px 0px #000, -3px 4px 0px #000, -5px 4px 0px #000, -4px 5px 0px #000, -6px 5px 0px #000, -5px 6px 0px #000, -7px 6px 0px #000, -6px 7px 0px #000, -8px 7px 0px #000, -7px 8px 0px #000, -9px 8px 0px #000, -8px 9px 0px #000, -10px 9px 0px #000, -9px 10px 0px #000, -11px 10px 0px #000, -10px 11px 0px #000, -12px 11px 0px #000, -11px 12px 0px #000, -13px 12px 0px #000, -12px 13px 0px #000, -14px 13px 0px #000, -13px 14px 0px #000, -15px 14px 0px #000, -14px 15px 0px #000, -16px 15px 0px #000, -15px 16px 0px #000, -17px 16px 0px #000, -16px 17px 0px #000, -18px 17px 0px #000, -17px 18px 0px #000, -19px 18px 0px #000, -18px 19px 0px #000, -20px 19px 0px #000, -19px 20px 0px #000, -21px 20px 0px #000, -20px 21px 0px #000, -22px 21px 0px #000, -21px 22px 0px #000, -23px 22px 0px #000, -22px 23px 0px #000, -24px 23px 0px #000, -23px 24px 0px #000, -25px 24px 0px #000, -24px 25px 0px #000, -26px 25px 0px #000, -25px 26px 0px #000, -27px 26px 0px #000, -26px 27px 0px #000, -28px 27px 0px #000, -27px 28px 0px #000, -29px 28px 0px #000, -28px 29px 0px #000, -30px 29px 0px #000, -29px 30px 0px #000;
}
<div class="box"></div>

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

pressing the button again will yield a new outcome

I am looking to disable a button (material ui) when it is clicked for the second time by setting disabled={true}. Unfortunately, I have not been able to find any examples related to this specific scenario on StackOverflow. <Button onClick={this.s ...

"Help needed: The HTML dialog element is obstructing the invisible reCAPTCHA challenge popup. Any solutions for resolving this

Visit this link to access the example in incognito mode. Click on the "open" button to open the sample signin form, then click on the "Sign Up" button to trigger the challenge. There seems to be an issue with using recaptcha inside a dialog. I'm not ...

The switch statement remains unchanged for varying variables

Here is some code that I am working with: updateTable(selectedIndex) { console.log("running updateTable function"); let level = ''; // if (selectedIndex == 1){ // this.setState({level: 'day'}) // th ...

Why is the Id not displaying correctly? Instead of showing the id, it is displaying Game Object(none)

I am currently working on a website that utilizes IDs for various pages under the path 'games/(id)'. When I create an object in the database table 'games' and pass it to HTML using context, Django recognizes its existence without giving ...

Using jQuery for transferring data from one page to another resulted in an undefined index error in PHP MySQL

This is my first project where I implemented Jquery for the first time. The project consists of two pages: 1. listofleaders.php and 2. leadersprofile.php On the first page, listofleaders.php, there is an input text box where users can enter a leader' ...

Prevent the ability to select text everywhere except for a specific class

My website has all text set to be non-selectable, except for input and textareas, with the following CSS code: *:not(input, textarea) { -webkit-touch-callout:none; -moz-user-select:none; -khtml-user-select:none; -webkit-user-select:none; -ms-user-select:no ...

I’m looking to incorporate my new CSS style file into the theme on OpenCart. How can I go about doing that?

When it comes to my homepage, I'm looking to have a unique stylesheet that differs from the default one. I want one that can override the default styles with my custom sheet. Despite trying numerous solutions, I haven't been able to achieve the ...

Link to toggle a CSS spoiler button

Currently, I have Ajax set up to replace the main div with a link. In addition, there's a spoiler-type navigation that allows you to hide or show the menu. I have my links inserted in this structure and am trying to figure out how to make it so that c ...

Tips for creating horizontal dividers with CSS in Vuetify using <v-divider> and <v-divider/> styling

Currently, I am working on a project using Vue.js and adding Vuetify. However, I need to use a component. .horizontal{ border-color: #F4F4F4 !important; border-width: 2px ; } <v-divider horizontal class=" horizontal ...

Is there a way to automatically reset a datepicker using the on.change function?

I've attempted various methods to clear/reset the value for a datepicker using the on.(change) function, but have been unsuccessful. The Air Datepicker plugin is being used in conjunction with Bootstrap 4. HTML <select title="-- NODE --" id="node ...

Unable to successfully implement the Bootstrap dropdown feature in my header upon switching pages

Utilizing Ruby on Rails and Bootstrap 5.3 to develop a website for showcasing my projects and information. I have a header file that contains all of the navbar code. Once I visit any link from one of the dropdown options, the dropdown button stops function ...

Incorporating dynamic text into a PHP/HTML webpage

I am currently developing a website that features a section displaying varying text based on the link clicked by the user. I have explored if-else statements, embedding objects, and using the onclick command. Below is some basic code I have drafted. Could ...

Saving user input fields such as input boxes, dropdown menus, and checkboxes within an .hta file allows for the information to be stored and accessed by either the original user or another user

Seeking assistance with an .hta file I'm developing for work. While proficient in HTML, JavaScript is a different story for me. I usually piece together examples to achieve my goals but this one has me stumped. Currently, I've created an .hta al ...

Enhance your website with a MultiItem Bootstrap Carousel SlideShow next to a Basic SlideShow feature

As I'm designing a website, my goal is to showcase products using sliders. I've implemented both a simple Carousel slideshow and a multi-item Slide Show on the same page. The multi-item Slide Show has a specific CSS class associated with it. The ...

Challenges with custom select boxes in Firefox

Is anyone else experiencing issues with a custom select box in Firefox? It seems like the problem might be related to the code snippet below: $(".custom-select-trigger").on("click", function() { $('html').one('click',function() { ...

Encase the message in a mat expansion panel if it exceeds a certain length

I am working on wrapping an XML message in a mat-expansion-panel to ensure it flows down if the content is too long, instead of extending beyond the panel boundaries. <mat-expansion-panel class="panel"> <pre>{{pretty(message.content ...

Dynamic header feature that maintains the aspect ratio of the logo image

Currently, I'm faced with the challenge of fixing the main grid on a website that I am currently working on. My objective is to minimize the use of media queries as much as possible. I am looking to ensure that the Logo Image maintains the height of ...

CSS rules must include specified units

I am fairly new to CSS and have a question about specifying units in the code below. Without specifying units for height and width, the text fits on one line. However, once I add 'px', the text occupies two lines instead. Can anyone explain what ...

Removing a session when the client has left

I wanted to simplify what I'm trying to achieve. Imagine two people have PHP sessions on a webpage. One person leaves the page while the other remains. After 60 seconds, the session of the person who left should be terminated automatically (like a ti ...

Attempting to create a dynamic layout for the objects using media queries and flexbox, however, the results are not as expected

.container { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; flex-direction: column; } .item { margin: 10px; border: 1px solid lightgray; border-radius: 10px; overflow: hidden; width: 100%; } @media scree ...