Creating a gradient circle in the header menu of your WordPress site

I am absolutely in love with the half CSS gradient circle featured on this WordPress website, but I'm struggling to implement it myself. Here is the URL for reference:

Could someone please provide me with detailed instructions on how to achieve this effect? Thank you so much!

Answer №1

The concept

  • Imagine a large circle, represented by a div with the CSS properties border-radius: 100% and width: greater than or equal to its containing element.
  • Conceal half of the circle from view at the top.
  • Horizontally align the circle at the center of its container.

Adjust the size (width, height) and positioning (top, left) relative to its containing element using percentage units and apply position: absolute. Ensure that the circle is placed inside a container with position: relative.

Visual representation

The red portion represents the viewport (what is visible):

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

Demonstration

An example showcasing a responsive design approach:

.container {
  display: grid;
  place-content: center;
  overflow: hidden;
  position: relative;
  min-height: 100vh;
  min-width: 100vw;
}

.gradient {
  background: linear-gradient(180deg, #e9fff8 59.5%, #a7edd4);
  border-radius: 100%;
  height: 100%;
  width: 100%;
  top: -50%;
  position: absolute;
  /* Move it behind other elements */
  z-index: -1;
}

@media screen and (max-width: 480px) {
  .gradient {
    width: 200%;
    left: -50%;
  }
}


/* Styles below are irrelevant to the main functionality */

* {
  margin: 0;
}
<div class="container">
  <div class="gradient"></div>
  <div class="content">
    Lorem ipsum dolor sit amet.
  </div>
</div>

Answer №2

To create a circular shape using CSS, you can utilize the border-radius property on a div element and set it to 50%. This will result in a round div. Additionally, you can add a gradient background by using the background property with linear-gradient and positioning it at the top middle of the circle. Adjusting the size of the div can also help enhance the overall appearance.

.gradient-circle {
  position: absolute;
  left: 0;
  top: 0;
  transform: translateY(-50%);
  background: #53fdff; /* fallback */
  background: linear-gradient(0deg, #53fdff, #74ffc1);
  border-radius: 50%;
  width: 100vw;
  height: 100vw;
}
<div class="gradient-circle"></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

Buttons and links with intricate geometries

I am currently developing a web application using Java/JSF and I am interested in finding out about technologies that would allow me to define intricate shapes as clickable buttons or links. Right now, my only option is to split an image into smaller trans ...

Database query results displayed in a vertical scroll block

I'm facing an issue with the placement of a DIV tag on my page. I have a large number of rows being returned from a database query, and I can't seem to get the DIV tag in the right location. When I put the DIV tag outside the while loop, it appea ...

Attempting to align the fixed banner in the middle of my blog

I have spent hours combing through code after code on this site, trying to center my fixed banner without success. I am feeling frustrated and in need of some assistance. Here is the CSS snippet I have been working with: .heading { position:fixed; ...

VueSax notifications are showing up in the wrong place

Could it be my fault or is it due to the alpha status of vuesax that the notifications I want to use are displaying incorrectly? Here is the code extracted from the documentation: openNotification (title_, text_) { //This code is placed inside Vue methods ...

The impact of Opacity CSS on child elements in web design

Struggling to show an error message when a user disables JavaScript. In my current work, I have two div layers - one covering the entire page and another on top to display the warning message. However, I'm facing issues with the opacity settings affec ...

Are the site-wide navigation links working on one page but not the other?

Currently, I am in the process of constructing a website on rails and have successfully integrated a site-wide navigation bar to display on all pages. However, an issue has arisen where the navbar is visible on both pages, yet the links and hover effects a ...

CSS not aligning email header correctly

I have been given the task of coding an HTML email for mailing campaigns. I have managed to get everything working, except for a particular piece of code. What I am trying to accomplish is having an image with other elements on top such as titles, a button ...

The updated version of Angular from 13 to 16 has implemented a new default value for primary colors

I recently upgraded my angular (+material-ui) system from version 13 to 16, and encountered an issue with the primary color of my custom theme. It seems that the value is no longer being recognized and defaults to blue. After updating the angular version, ...

What is the best way to transform this into an HTML readable code?

While browsing through a template, I came across this code and I'm unsure of how to get it functioning. I've tried removing the comments, but unfortunately it doesn't seem to be working as expected. li.dropdown.navbar-cart ...

What is the method for incorporating text below font icons?

Having a bit of trouble here with my code snippet featuring 'font awesome' icons in circles. I'm looking to add text beneath each icon, but the alignment within the circle is proving to be a challenge. Check out the code in this link to see ...

Alter the navigation background when moving between sections on a one-page website

I need to ensure that the background of the navigation remains transparent on the "home" section. However, when switching to other sections, the background color of the navigation becomes permanently black. <header class="clearfix"> <nav> ...

Creating a dynamic 2x2 grid with centered responsiveness in Angular Ionic framework

I'm having trouble achieving a 2 x 2 grid that is centered on my screen. The code snippet below shows what I have so far in the HTML file. Just to provide some context, this project is meant for a native mobile application. <ion-header> <i ...

Exploring the Transition from React.js with Material UI to Next.js for Server-Side Rendering: A Comparison of Tailwind CSS, Material UI, and Chakra UI

Currently, I am in the process of moving my React.js application with Material UI components to Next.js for server-side rendering (SSR) while considering some UI changes. In my research, I have come across three UI frameworks: Material UI, Chakra UI, and T ...

Using CSS to create a strikethrough effect on prices with spacing

I have a woocommerce setup and I want to showcase the original prices by striking them out like a price tag when products are on sale. However, there seems to be an issue with the space that woocommerce automatically adds between the currency and the pric ...

What is the best way to extract a single image from JSON data using AngularJS?

Using ng-repeat in HTML, how can I display only a single image instead of all images? <img class="size" ng-src="{{image.image}}" /> In CSS, I aim to define the size of the image. .size { margin-left:0.3em; width:11em; height:11em; border:0.4em sol ...

Modify the background color of one div based on the visibility of another div

My carousel consists of three divs representing a Twitter post, a Facebook post, and a LinkedIn post. These are contained within another div called #social-media-feeds. I am curious if it is feasible to adjust the background color of #social-media-feeds d ...

The Challenge of CSS Transition and Checkbox Label Discrepancies

I'm looking to adjust the position of my label when a checkbox is checked. Everything works smoothly if I don't include a transition for the top offset property in the CSS of my label. However, when this transition is added (as seen in the commen ...

Tips for aligning a div underneath another div in a centered position

I am attempting to align .rij_lessenrooster below .rij_weekdagen so that it is centered under each day. The teacher advised me to create a column and then try it, but it did not resolve the alignment issue. The .rij_weekdagen consistently appears off to th ...

Angular 2: Dealing with Missing Image Loading

When viewing an HTML file containing the following code: <div> <img src="New-Google-Logo.png"/> </div> The image file New-Google-Logo.png is expected to load from the same folder as the HTML file. However, after running ng s ...

Tips for Creating a Responsive Homepage

I'm new to CSS and trying to create a responsive design for mobile IE. Currently, the page appears blank on IE but works fine on Google Chrome and other browsers :-) Here are the code snippets I have used: HTML: <div class="main"> <div ...