Developing shapes using CSS and jQuery

I am struggling to create the exact contour as shown in the image. Despite trying, I have not been successful in achieving it. I used a lot of HTML child tags in my attempt, but I would prefer to keep it minimal. Is there a simpler way to accomplish this?

*{margin: 0; padding: 0; box-sizing: border-box;}
        .parent, .child {
            display: flex;
            border: 1px solid gray;
        }
        .parent {
            width: 50%;
            height: 100vh;
            justify-content: center;
            align-items: center;
        }
        .child {
            padding: 15px;
            border-radius: 50px;
        }
        .one {width: 20vw; height: 15vh;}
<div class="parent">
        <div class="child">
            <div class="child">
                <div class="child">
                    <div class="child">
                        <div class="child">
                            <div class="child">
                                <div class="child">
                                    <div class="child">
                                        <div class="child">
                                            <div class="child">
                                                <div class="child one">img</div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

https://i.sstatic.net/RZAMx.png

Answer №1

Have you considered using a single box-shadow instead of utilizing multiple div elements and multiple CSS classes?

img {
  margin:60px;
  background-color:#eee;
  width: 20vw; height: 15vh;
  border-radius: 50px;
  box-shadow:
    0 0 0 2px #aaa,
    0 0 0 10px #eee,
    0 0 0 12px #aaa,
    0 0 0 20px #eee,
    0 0 0 22px #aaa,
    0 0 0 30px #eee,
    0 0 0 32px #aaa,
    0 0 0 40px #eee,
    0 0 0 42px #aaa,
    0 0 0 50px #eee,
    0 0 0 52px #aaa,
    0 0 0 60px #eee;
}
<img src="" alt="Image">

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

Obtain the printed value of a button via PHP and manipulate it using JavaScript

I have a dynamic table that displays results from a database. <table id="table" class="table datatable-responsive"> <thead> <tr class="bg-teal"> <th>#</th> <th>Date & Time</th& ...

After the completion of progress, display the POST outcome

One feature I have implemented is a progress bar that displays the progress made when a user inputs a value into a form and submits it. Based on this input value, a query is executed by the system a specified number of times to add records, which are then ...

Refresh the page once the function has been executed

Recently, I came across a basic javascript code that I need some help with. I want to reload the page after certain elements have faded out and back in. The problem is, I'm not sure where exactly I should include the window.location.reload(); function ...

Exploring the process of passing parameters in Material-UI React styled components

Recently, I developed a new component const CategoryDialog = (props) => { const classes = useStyles(); console.log(props); return ( <div> <Dialog fullScreen open={props.dilaogOpenProp} TransitionCompone ...

Unable to locate the tag using .find() function following the use of .attr() method

I am currently utilizing jQuery in conjunction with node-horseman to interact with a specific page. My approach involves referencing the page's data-id attribute, which I then pass to my application to search for the li element containing this attribu ...

Is it possible to retrieve a callback function from a select event in the Bootstrap dual listbox?

I'm fairly new to front-end development and have been using the Bootstrap DualListbox for a project. I'm looking for a way to save items moved from one list to another to a database before they are officially transferred. Is there a callback func ...

Convert specific form inputs into an array

I have a form that includes various inputs, but the ones I am focusing on are labeled attributes[] and options[$index][]. Here is an example of the data found in my attributes[] input: Array ( [0] => Size [1] => Color [2] => Material ) Not ...

JQuery: How to Toggle Elements and Remove Classes

Having a bit of trouble with this one. I've got a link called #title that toggles the visibility of div #content when clicked. Everything is working fine, but for some reason, the "active" class remains on the #title link even after using removeClass. ...

How can I apply specific styling to certain cells within a table?

Is there a way to apply styles specifically to certain table headers in an HTML table without altering the HTML or introducing JavaScript? I need to target only 4 out of the total 8 table headers. To see the code and example for this question, visit: http ...

Sending a parameter from a click event to a function

Struggling with a jQuery and AJAX issue all night. I am new to both and trying to implement something similar to this example. I have an edit button with the ID stored in a data-ID attribute. Here's an example of what my button looks like: <butto ...

What's the reason for not being able to customize classes for a disabled element in Material-UI?

Currently, I am utilizing Material-UI to style my components. However, I am facing challenges when trying to customize the label class for disabled buttons. Despite setting a reference as "&$disabled", it does not yield the desired results. import Rea ...

The agreement button is unclickable for the bot due to a selenium element interaction issue

<input id="agreement-input-mobile" class="agreement-input" type="checkbox" name="agreement" aria-describedby="agreement-content"> When attempting to automate a specific task, I encounter an issue whe ...

``Are there any thoughts on how to troubleshoot display problems specifically on mobile

Whenever I use Safari on iOS for my web application, I encounter strange rendering issues. It's odd because the majority of the time everything functions as it should, but every now and then these bugs crop up with no discernible pattern. Examples th ...

How can a Vue.js toggle button dynamically change based on the combined state of two checkboxes?

My current project involves implementing a toggle feature that allows users to enable a day and then select between AM or PM using checkboxes. One issue I'm facing is how to de-toggle the button if a user unchecks both AM and PM options. Check out t ...

Enhancing Image Quality in JavaFx's Scene Builder

Hey everyone! I've been using JavaFx scene builder to create a user interface with some png images. Up to now, I've been using labels and enlarging them to display the pictures, but this solution isn't ideal because I need to create multipl ...

Python code snippet for transforming JSON data into an HTML table

Recently, I've been utilizing the JSON library in Python to extract data from JSON files through Python. extractedData = json.loads(jsonfile) While I have a solid grasp on handling JSON files with Python, I am now exploring ways to present JSON data ...

I'm having trouble getting jquery css to function properly in my situation

I am trying to implement a fallback for the use of calc() in my CSS using jQuery CSS: width: calc(100% - 90px); However, when I tried running the code below, it seems like the second css() function is not executing. I suspect that there might be an issu ...

Code for dynamic drop down menu and pagination using PHP and HTML

I'm struggling to understand the logic behind adjusting the number of images displayed on my page. I can't seem to select the first option (5) from the dropdown menu. No matter what I choose, it always defaults to showing 10 images. This issue ...

To make the Bootstrap 4 spinner/loader gracefully disappear when the browser window has finished loading, utilize the fadeOut() or hide() function

THE GOAL My objective is to display a spinner/loader while the browser window is loading, and then have it fade or hide once the page is fully loaded. EFFORTS MADE I've attempted to use a jQuery code recommended in a different question (How to show ...

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 ...