Reducing the size of a collection of CSS shapes

I'm attempting to position a group of elements in the top left corner of a webpage. Everything looks good when the browser is at its maximum width. However, once the browser width decreases to less than the width of the largest element (outer-circle of 927px), a horizontal scrollbar appears. I want the elements to scale down dynamically to prevent the appearance of the scrollbar. While I could individually resize each element using media queries, I am curious if there's a more efficient way to achieve this.

I experimented with placing the group inside a bootstrap column, but that did not solve the issue. I also tried setting the element sizes in viewport units (e.g., setting .inner-circle width and height to 20vw). This approach seemed to work initially, but as I resized the browser window, the elements moved off the page.

Here's the HTML code:

<div class="corner">
        <div class="moon"></div>
        <div class="inner-circle"></div>
        <div class="mid-circle"></div>
        <div class="outer-circle"></div>
</div>

And here's the CSS code:

.moon{
    position: absolute;
    width: 240px;
    height: 240px;
    left: 170px;
    top: -40px;   

    border-radius: 50%;
    box-shadow: -80px 50px white;
}                   
.inner-circle {
    position: absolute;
    width: 635px;
    height: 598px;
    left: -134px;
    top: -300px;

    border-radius: 50%;
    background:rgba(229, 227, 238, 0.5);
    opacity: 0.4;
}
.mid-circle {
    position: absolute;
    width: 841px;
    height: 795px;
    left: -240px;
    top: -400px;

    border-radius: 50%;
    background: rgba(229, 227, 238, 0.5);
    opacity: 0.3;
}
.outer-circle {
    position: absolute;
    width: 927px;
    height: 902px;
    left: -230px;
    top: -410px;

    border-radius: 50%;
    background: rgba(229, 227, 238, 0.5);
    opacity: 0.2;
}

Answer №1

Consider providing values in percentages rather than pixels, allowing for better adjustment based on screen size. Alternatively, you can specify position relative to the parent div 'corner'.

Answer №2

Consider applying these css attributes:

max-width: (your width)px;
width: 100%;

By implementing this, your div will scale down as the screen size decreases below the specified width.

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

Enhancing progress through cleanliness

When developing a website, I am implementing progressive enhancement to ensure accessibility and SEO friendliness. This approach involves structuring elements like the menu and slideshow as unordered lists in the page markup, with JavaScript handling the s ...

What is the best method for dynamically extracting CSS files from websites using user input?

I'm currently involved in a group project that involves ranking website designs based on the number of colors they contain. I was able to successfully use regex to analyze a 'style.css' file for color counting, but now I'm facing challe ...

I wish to have the sidebar shown initially, then be able to collapse it by clicking a button and adding a dropdown feature to the side of the menu items using Bootstrap

I am looking to implement a sidebar menu using Bootstrap. I want the ability to hide the menu, even on larger screens, by clicking a button. When collapsing the menu to the left side, I want the icons to display on the left as well. Clicking on a menu i ...

Adjust the position and size of an image by hovering over it with your

I'm currently working on implementing a button menu for my website, but I'm facing an issue with the hover effect on images. You can check out what I've done so far at http://jsfiddle.net/tNLUx/ What I want to achieve is when hovering over ...

Why does the border still appear when I have set border-style:none; on my anchor tags and click on a link?

Looking at the example provided below, I have a black background and red links to highlight the issue of dotted borders appearing on my links when clicked. Despite adding border-style:none, the dotted border still persists. Is there an alternative method ...

Having trouble executing javascript with Ext.Ajax in Sencha-Touch2?

Currently, I am utilizing htmlPanel.js in Sencha-Touch as discussed in the Forum here to exhibit local HTML content. Even though I can load the HTML content with standard HTML tags, I'm facing issues with loading JavaScript. Here's the snippet o ...

Customize the appearance of every other column in an asp gridview

Looking for help with formatting rows and columns in an ASP GridView. The rows are automatically colored alternating, and I want to make the content in every first column bold and every second column normal. I have heard about using CSS nth-child() to achi ...

Check if the element is located on the active tab using jQuery

I have implemented a tab system to organize a lengthy form with multiple input fields. The form consists of 4 tabs, and beneath them, there is a preview section displaying the user's selections. In this preview area, I added icons that enable users ...

Is there a way to create a hyperlink that automatically opens in a new page with just HTML?

Although this may be a simple request, I would greatly appreciate your assistance with my computer science project. Thank you in advance! ...

Transforming HTML template into Thymeleaf format

Having trouble converting my HTML5 template for a spring project using Thymeleaf. I've changed all script src to th:src and style files (CSS files too) to th:href, but the design isn't displaying correctly. <script th:src="@{/resources/js/jqu ...

Using res.write() in Node.js to display text on a web page as a single line

On the display, every line of text appears on a single line and it utilizes the <br/ >. res.write("stuff" + "<br/>" + "more stuff"); res.write("words <br/> more words"); res.send(); output = stuff ...

I can't seem to figure out why this file upload error is happening. What could be the

Having trouble with a simple file upload function and keep getting an "Error" message when trying to use it. Here's my HTML file: <form enctype='multipart/form-data' action='upload.php'> <input type='file' name ...

Adding an arrow to a Material UI popover similar to a Tooltip

Can an Arrow be added to the Popover similar to the one in the ToolTip? https://i.stack.imgur.com/syWfg.png https://i.stack.imgur.com/4vBpC.png Is it possible to include an Arrow in the design of the Popover? ...

What is the best way to customize the cursor for each individual div?

Can you alter the cursor from a pointer to "not-allowed" within the div or GridList element in ReactJS or Material UI? ...

The numbering in the list does not align vertically with the corresponding content

I am attempting to create an ordered list with collapsible sections inside the li elements. The goal is to display basic information about a specific context, and when clicking on a link, additional details are shown. While the code is functional, I am fac ...

Display 4 images in a vertical layout without any padding, while ensuring responsiveness

Thank you to everyone for all the help! I have learned so much from your continuous support. I am working on creating a 4-way vertical "collage" of images with no spaces between each picture, that is fully responsive when resizing the window. However, I a ...

Utilize duplicate named CSS grid rows as a reference

Summary; This method currently works, but it requires adding multiple nth-child selectors for each new person and their answer. I am seeking a solution that can dynamically handle any number of rows using an even and odd selector to simplify the process. ...

Posts labeled with tags are not properly paginating

I've been working on a Django application that showcases posts created through Django's admin interface. These posts include tags implemented using django-taggit () The main page (home.html) is designed to display both posts and their respective ...

Setting a Fixed Default Value in an Angular Dropdown Menu

Within my code, there is a specific column where users have the ability to insert an element and choose its priority type while doing so. I am currently attempting to assign a default value to the dropdown selection (row.PriorityType.Id ==1). Although I at ...

Ways to add padding while ensuring the element remains responsive

Whenever I try to add padding to an element, it ends up losing its responsiveness when the window is resized. I am using Reactjs with React-bootstrap, and I believe the issue lies in the way I am setting the padding on the element. Interestingly, when I re ...