Various Overlay Shapes in Bootstrap Using CSS

So I'm in the process of styling my landing page with CSS based on a design I have in Figma. The page is using Bootstrap 5 as its framework, though I'm not sure if that detail matters in this case. I believe it's definitely doable, but I'm struggling to figure out the best approach to achieve the desired look.

Initially, I thought about creating three divs - Oval1, Oval2, and Oval3 - and positioning them relatively while using overflow hidden to clip them. However, resizing the ovals seems to affect the size of all the content within the column.

I know that it's possible to closely replicate the design, but I just need guidance on the most effective way to tackle this. Your assistance would be greatly appreciated. Take a look at these screenshots for reference: https://i.sstatic.net/Fyk18qBV.png

https://i.sstatic.net/8n7Yp5TK.png

<div class="col-lg-6 d-flex align-items-center login_screen_img">
                    <div class="text-white px-3 py-4 p-md-5 mx-md-4">
                        <div class="oval1"></div>
                        <div class="oval2"></div>
                      <h4 class="mb-4">We are more than just a company</h4>
                      <p class="small mb-0">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                        tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
                        exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
                    </div>
                  </div>

  .col-lg-6.d-flex.align-items-center.login_screen_img {
    background-image: url(../img/login-pg-bg.png);
    background-position: 45% 36%;
    overflow: hidden;
}


/*shape overlays*/

.oval1 {
    position: relative;
    width: 319px;
    height: 187px;
    background: #4AC676;
    opacity: 85%;
    border-radius: 50%;
    bottom: -330px;
    left: -154px;
}

.oval2 {
    position: relative;
    width: 319px;
    height: 187px;
    background: #4AC676;
    opacity: 85%;
    border-radius: 50%;
    bottom: -120px;
    left: -100px;
}

Answer №1

In place of using the <img> tag, consider utilizing the background-image CSS property. Achieve this by applying position-absolute along with position-relative, z-index, left, and bottom.

To cater to different viewport sizes, employ @media queries for adjusting the sizes of green circles accordingly. Although it may appear unattractive on various viewport sizes, at 810px width (the viewport size used during code creation), the design would resemble this:

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

Implement @media queries to ensure consistency across other viewport dimensions.

Refer to the code snippet below.

.circle1 {
  position: relative;
  width: 650px;
  height: 650px;
  background: #4AC676;
  opacity: 85%;
  border-radius: 50%;
  bottom: -60%;
  left: -10%;
}

.circle2 {
  position: relative;
  width: 450px;
  height: 450px;
  background: #4AC676;
  opacity: 50%;
  border-radius: 50%;
  bottom: -40%;
  right: -100px;
}

.circle3 {
  position: relative;
  width: 250px;
  height: 250px;
  background: #4AC676;
  opacity: 25%;
  border-radius: 50%;
  bottom: 25%;
  right: -10%;
}
<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Test title</title>

  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ec8e8383989f989e8d9cacd9c2dfc2df">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"></head>

<body>
  <div class="row><div class="col-lg-6 d-flex align-items-center position-relative overflow-hidden">
    <img class="w-100 object-fit-cover" src="https://www.thesafaricollection.com/wp-content/uploads/2022/07/The-Safari-Collection-Hey-You-Giraffe-Manor-1.jpg">
    <div class="circle1 position-absolute"></div>
    <div class="circle2 position-absolute"></div>
    <div class="circle3 position-absolute"></div>
    <div class="text-white px-3 py-4 p-md-5 mx-md-4 position-absolute left-0 bottom-0 w-50"><h4 class="mb-4>We are more than just a company</h4><p class="small mb-0>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p></div></div></div><script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4e2c21213a3d3a3c2f3e0e7b607d607d">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script></body></html>

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

I'm noticing my table collapsing as I move around the div elements - any idea why this is happening

A challenge I am facing is creating a dynamic table where users can drag and drop colored boxes with animated transitions. While it mostly works well, sometimes the table collapses inexplicably. Here are steps to reproduce the issue: Move 100 - 400 Move 1 ...

Interconnected HTML div values impacting one another

Forgive me for the not-so-great title, as I am unsure of what this particular HTML coding method is called. That's why I am asking this question in the first place. I've written some code and I need to know what type of coding practice this is. ...

Automatically collapse the responsive menu upon selecting a menu item

I have implemented a custom JavaScript code for a basic open/close menu movement on multi-page websites. The code works by closing the menu only when the user clicks the menu symbol. However, I now need to incorporate this code into a one-page website and ...

After the page is reloaded, apply a class to the divs by selecting them based on the "data" attribute

I have a set of four cards labeled "card", each representing different body parts: eyes, torso, arms, and legs. <div class="card" data-lesson="eyes">eyes</div> <div class="card" data-lesson="torso">torso</div> <div class="card" ...

CSS Techniques for Smooth Transitions

When the hamburger icon is pressed, a menu appears over the current page with CSS from Glamor. The menu slides in perfectly from the right side of the screen, but I am having trouble getting it to slide out when any part of the menu is clicked. I have def ...

Looking for assistance with CSS to properly align a dozen items

UPDATE: See the current layout in this JFiddle based on feedback received from others, still a few tweaks needed. In my setup, there are 12 divs housed within one container div. These 12 divs consist of 6 text components and 6 corresponding input fields. ...

Angular and Bootstrap combined to create a versatile navigation bar with a collapsible sidebar feature

Currently, I am in the process of developing a progressive web app using Angular and Bootstrap. One of the main challenges I am facing is implementing a navbar that not only looks great on desktop but also on mobile devices. So far, I am satisfied with my ...

Different method for adding child elements to the DOM

When creating a DOM element, I am following this process: var imgEle = document.createElement('img');     imgEle.src = imgURL;             x.appendChild(imgEle); Instead of appending the last line which creates multiple img elements ev ...

Update Table Row Background Color in Separate Table by Clicking Button Using JQuery

Two tables are involved in this scenario - one that receives dynamically added rows, and another that stores the data to be included. The illustration above displays these tables. Upon clicking the Edit button, the information from the selected row in Tab ...

Tips for establishing a fixed point at which divs cease to shrink as the browser size decreases

There are numerous dynamically designed websites where divs or images shrink as the browser size decreases. A great example of this is http://en.wikipedia.org/wiki/Main_Page The div containing the text shrinks proportionally to the browser size until it ...

JavaScript Birthday Verification: Regular Expression Pattern

I am currently testing out JavaScript form validation. The information provided is not being sent to any database, it's just for format testing purposes. All the regex checks are functioning correctly apart from birth. It seems like there may be an i ...

CSS not working when attempting to override Angular (13) Material file

In my Angular (13) application with Material, I have developed a CSS file specifically for overriding certain Material styles. This CSS file is imported into the styles.scss file as the last line. However, despite importing the external file, the CSS def ...

Rotate the circular border in a clockwise direction when clicked

I have successfully designed a heart icon using SVG that can be filled with color upon clicking. Now, I am looking to add an outer circle animation that rotates clockwise around the heart as it is being created. Currently, the circle only spins in the code ...

Can you explain the meanings of <div class="masthead pdng-stn1"> and <div class="phone-box wrap push" id="home"> in more detail?

While working on styling my web pages with CSS and Bootstrap, I came across a few classes like "masthead pdng-stn1" and "phone-box" in the code. Despite searching through the bootstrap.css file and all other CSS files in my folders, I couldn't find a ...

When attempting to input data into the database, an error is displayed stating that /test.php cannot be POSTed

Every time I try to input data using PHP, it throws an error Cannot POST /test.php. I've been attempting to fix it with no success. Can anyone please help me solve this issue? It's crucial for my project work. Here is my HTML code: <html> ...

Navigating to the following webpage with Selenium using Python

url_main = "https://comic.naver.com/webtoon/detail.nhn?titleId=131385&no=292" This particular website features a comment pagination at the bottom of the page. Upon inspecting the page, I noticed that the buttons were structured like this: &l ...

The show more/show less link for a long jQuery paragraph is malfunctioning

I encountered an issue while coding where the "read more" link works correctly, but the "show less" link does not. Despite my efforts, I cannot seem to identify the error. Within this code snippet, there is an anchor tag with class="show-less" that I am u ...

`JQuery fadeOut seems to have a limitation where it only applies to the

I have a group of divs, each containing an anchor tag that triggers a JavaScript function (which uses AJAX to delete a row from a table). Here's an example setup: <div id="container"> <div><a id="btn" onclick="deleteRow()">Delet ...

Having trouble inserting a new row into the AngularJS table?

Having trouble adding a new row to the table in angularjs when clicking the add button. Here is the link to the Plunkr example -https://plnkr.co/edit/s7XAaG4JbvbTTxiZ0V2z?p=preview The HTML code snippet is as follows: <html> <head> <script ...

Tips for accessing CSS properties on the img tag

I could use some assistance with CSS. I am in the process of creating a tree structure using many <ul> and <li> tags. The issue arises when I have multiple <li> elements with a specific class, each containing an <img> tag. How can ...