What's the best way to move a CSS shape off the bottom of the screen?

I'm attempting to recreate this design concept.

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

I was able to push the top circular shape out of the screen as shown in the image. However, I'm facing an issue with the bottom shape - it's just extending the webpage instead of going off the screen. How can I push it out of the screen like in the example?

#circleTop {
    width: 55rem;
    height: 55rem;
    background-image: linear-gradient(120deg, red, yellow);
    border-radius: 50%;
    position: absolute;
    z-index: -1;
    left: 60%;
    top: -35rem;
}

#circleBottom {
    width: 50rem;
    height: 50rem;
    background-image: linear-gradient(120deg, green, blue);
    border-radius: 50%;
    position: relative;
    z-index: -1;
    right: 45%;
    bottom: -35rem;
}

<div class="header">
            <div id="circleTop"></div>
            <div class="headerBox">
                <h1>Headline</h1>
                <h2>Subheading</h2>
            </div>
        </div>
 ....

<div class="footer">
           <div id="circleBottom"></div>
            <div class="section">
                <a href="#">Link</a>
                <a href="#">Link</a>
            </div>
            <div class="otherLinks">
                <p>Lorem Ipsum Dolor Sit Amet</p>
            </div>
        </div>

Answer №1

In my opinion, the existing answers are on the right track but lack completeness. If you wish for your circle to be 'cut off' and not visible when scrolling down, it must be enclosed within another element that restricts its visibility. While using position:absolute; is a step in the right direction, it will position the element relative to the nearest containing element with a defined position - which is why adding position:relative; to your footer div is necessary. Additionally, ensure that the part of the circle meant to be hidden is indeed concealed by utilizing overflow:hidden. The following code snippet should guide you in achieving this:

.footer {
  position:relative;
  overflow:hidden;
}

It may not always be appropriate to apply these styles directly to the footer div, but the concept remains the same. Overflowing elements will remain visible and cause scrolling unless explicitly instructed otherwise. Therefore, creating the illusion of overflowing content by concealing or 'cropping' it within another element is key. While some suggest applying these styles to the body or html elements, opting for an element closer to the one you wish to hide is usually more consistent. For instance, setting a fixed height or using 'overflow:hidden;' on the body can prevent scrolling if additional content exceeds the screen height.

Answer №2

To implement a unique design for your webpage, make sure to include the following elements in your body and CSS:

body{
  position: relative;
  height: 100vh;
  overflow: hidden;
}
#circleTop {
    width: 55rem;
    height: 55rem;
    background-image: linear-gradient(120deg, red, yellow);
    border-radius: 50%;
    position: absolute;
    z-index: -1;
    right: -25rem;
    top: -25rem;
}

#circleBottom {
    position: absolute;
    width: 55rem;
    height: 55rem;
    background-image: linear-gradient(120deg, green, blue);
    border-radius: 50%; 
    z-index: -1;
    left: -25rem;
    bottom: -25rem;
}
<body>
  <div class="header">
    <div id="circleTop"></div>
    <div class="headerBox">
      <h1>Impressive Title</h1>
      <h2>Captivating Subtitle</h2>
    </div>
  </div>

  <div class="footer">
    <div id="circleBottom"></div>
    <div class="section">
      <a href="#">Visit Now</a>
      <a href="#">Learn More</a>
    </div>
    <div class="otherLinks">
      <p>Fantastic Content Here</p>
    </div>
  </div>
</body>

Answer №3

For the bottom left circle, use the following CSS class:

#circleBottom {
    width: 50rem;
    height: 50rem;
    background-image: linear-gradient(120deg, green, blue);
    border-radius: 50%;
    position: absolute;
    z-index: -1;
    left: -15%;
    bottom: -15%;
}

Check out this Circle example for reference.

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

Utilizing the Jquery Kenburner Slider: Playing a Local Video File

I am attempting to utilize the Kenburner slider to play a local video file, but instead of playing the video, it is initiating a download. Here is how I am trying to implement it: <iframe class=”video_clip” src=”http://localhost/cgi-bin/movies/12 ...

Can CSS be used to consistently position content in a specific manner?

I previously inquired about a similar issue and received an excellent solution. Here is my jsbin http://jsbin.com/nuwagibayo/1/edit?html,css,output where I encountered the following scenario: The positioning of 12.50 seems slightly awkward in its current ...

Transition from Material UI styles to SCSS equivalent

Can you assist me in converting the following Material UI themes to its equivalent SCSS? I am defining up("sm") as meaning above600px. I'm in the process of creating a @mixin contentShiftContainer so that I can use it wherever needed. Howev ...

Library of CSS styling information

Has anyone come across a reliable javascript library that can retrieve the original style (not computed) of a specific element in the DOM? Essentially, I am looking for something that can provide results similar to what is displayed in Firebug's style ...

Creating a CSS tag for a group of radio buttons involves styling the input elements for

https://i.sstatic.net/NPvOM.pngCurrently utilizing Vaadin 23 and recently attempted to incorporate a CSS style (outlined below) for radio buttons. However, I encountered random alignment issues with the selector options, as depicted in the image. My goal ...

The dual-column format is experiencing technical difficulties

Having some trouble creating a two column layout in an HTML page. I've posted my code on jsfiddle http://jsfiddle.net/bobbyfrancisjoseph/eFMpJ/35/ Struggling to set a top margin for the inner container, even though I've specified it in the CSS ...

What are some effective techniques for personalizing Bootstrap?

Recently, I have found myself facing numerous challenges with Bootstrap. Although I used it to create a website in the past, I haven't touched it since. However, circumstances have now led me to incorporate it into my current project. I have downloade ...

Browsing with PHP/HTML on Safari from Mac Os 10.6.5 seems to run at a sluggish pace

This is the program: <?php require_once 'swift-mailer/lib/swift_required.php'; $name = $_POST['name']; $email = $_POST['email']; $form_subject = $_POST['form_subject']; $form_message = $_POST['form_message ...

Discover how to execute a function depending on a specific button in Node.js using Express

How can I trigger a function based on which button is clicked? I am working with an EJS file named test.ejs <form> <input type="submit" value="Click here 1"></input> <input type="submit" value="Click here 2">&l ...

Extract the #id parameter from the URL using jQuery

Suppose I have a URL similar to this http://localhost/sites/fh/index.php#second. My goal is to extract the id from the end of the URL and save it in a variable container for later use in an if else statement within jQuery. What would be the best approach ...

Issues arise when attempting to determine the accurate dimensions of a canvas

Looking at my canvas element: <canvas id='arena'></canvas> This Element is set to fill the entire website window. It's contained within a div Element, both of which are set to 100% size. I attempted running this script: var c ...

Utilizing the Bootstrap grid system allows for input fields to automatically expand to 100% width once they reach

I am encountering some challenges while attempting to develop a responsive form using bootstrap grids. The issue seems to arise when resizing the browser window, as the grid classes behave unexpectedly by expanding and taking up the entire page width at ce ...

Disappearing Div Dilemma: The Mystery of the Responsive Design

I am currently facing an issue where two div elements (`.left` and `.right`) are not displayed vertically when the width value is less than 800px. Strangely, the `.left` div disappears when I try to adjust the width. I have shortened the code for clarity. ...

Using CSS to style PHP function results

I am working on a shopping cart application and I want to incorporate a condensed version of the cart onto my home page. The main shopping cart page is called 'modcart.php' and I have managed to integrate it into my homepage using the following c ...

Ways to Customize the Text Color in the Navigation Bar

Is there a way to change the color of text in my navigation bar to #b3b3b3? It seems like I am limited to the colors provided by bootstrap. How can I work around this limitation? <nav class="navbar" style="color: #b3b3b3; background-col ...

creating a stacked image effect with css

Question: How can I insert new_icon inside app_icon like the image below? One condition must be met: .img-icon and .td-icon cannot be altered CSS: .img-icon max-width: 100% min-width: 40px height: auto vertical-align middle margin-t ...

Creating a stylish web page with smooth, rounded corners using CSS styling techniques

Looking for some inspiration? Check out this free CSS sample template called Black Coffe. After downloading and opening it in Visual Studio, I noticed that the design time HTML appears as blocks. However, once compiled, it renders with aesthetically plea ...

A specific image is loading after being clicked in a new page

Despite my efforts to search on various platforms, I have not been able to find a comprehensive solution to my query. Scenario: I currently have a webpage containing a div with multiple images. These images load without any issues and are set to open in ...

Why do I need to control-click in order to download the link?

Lately, I have been operating a simple node.js server for hosting a website. However, recently, I encountered an issue where one of my download links began redirecting to the index.html page instead of initiating the download process for the PDF it is supp ...

Tips for resolving: 404 error when attempting to load a popup using Ajax

I am new to RoR, so I might be missing something. I am struggling with loading a popup through Ajax when a button is clicked. Every time I attempt it, I encounter an error related to the Ajax method as shown below. I believe my syntax is correct. I have ...