Combining two divs to share the same linear gradient and shadow effect

Greetings to all our valued partners!

I am seeking guidance on how to achieve the following task for a web application I am developing:

Within my webapp, I have designed a stylish NavBar similar to the examples depicted in the images (in AdobeXD it is displayed as a combination of a rectangle with a circle).

Check out the Nav Example in AdobeXD | View the complete design here

Is there a way to create this navbar using HTML/CSS?

Although I have some code already in place, I'm unsure about how to merge the div elements representing the rectangle and circle in order to maintain consistent shadowing and linear gradients. Is it feasible to achieve this effect? 🥺 Or would it be more efficient to export the nav design as an SVG file?

body{
  margin: 0;
}

.navContainer{
    width:100vw;
}

.mainNav{
  width:100vw;
  background: linear-gradient(#30355e 0%, #383e6e 100%);
  box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
  height: 73px;
  border-radius: 0 0 40px 40px;
  filter: drop-shadow(0px 5px 8px rgba(0, 0, 0, 0.25));
}

.circleNav{
  width:110px;
  height:110px;
  background: linear-gradient(#30355e 0%, #383e6e 100%);
  border-radius: 50%;
  position: absolute;
  left: calc(50% - 57px);
  top: 10px;
  box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
}
<html>
  <div class="navContainer">
    <div class="mainNav">
    </div>
    <div class="circleNav">
    </div>
  </div>  
</html>

Answer â„–1

If you want to achieve this, follow the steps below:

body {
  margin: 0;
}

.navContainer {
  width: 100vw;
  filter: drop-shadow(0px 5px 8px rgba(0, 0, 0, 0.45)); /* applying filter on main container */
}

.mainNav {
  background: 
    linear-gradient(#30355e 0%, #383e6e 100%) 
    top/100% 110px; /* 110px = height of circle */
  height: 75px;
  border-radius: 0 0 40px 40px;
}

.circleNav {
  width: 110px;
  height: 110px;
  background: linear-gradient(#30355e 0%, #383e6e 100%);
  border-radius: 50%;
  margin: -75px auto 0; /* aligning with nav height */
}
<div class="navContainer">
  <div class="mainNav">
  </div>
  <div class="circleNav">
  </div>
</div>

Alternatively, you can use a more concise code like so:

body {
  margin: 0;
}

.navContainer {
  filter: drop-shadow(0px 5px 8px rgba(0, 0, 0, 0.45)); /* applying filter on main container */
  height: 110px;
}

.navContainer::before,
.navContainer::after{
  content:"";
  position:absolute;
  top:0;
  height:100%;
  border-radius: 50%;
  background-image:linear-gradient(#30355e, #a3aae4);
}

.navContainer::before {
  left:0;
  right:0;
  height:70%;
  background-size:100% calc(100%/0.7); 
  background-position:top;
  border-radius: 0 0 40px 40px;
}

.navContainer::after {
  left:50%;
  aspect-ratio:1/1; /* note that browser support for this is limited, you can use width:110px as an alternative */
  transform:translate(-50%);
}
<div class="navContainer">
</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

Navigating Checkbox in Active Choice Reactive Reference Parameter on Jenkins

I attempted to configure an active choice reactive reference parameter using the instructions outlined in this guide: Here is the code for the reactive reference parameter: service_tier_map = [ "web": [ ["service_name": "use ...

AngularJS - Sending configuration values to a directive

I'm trying to figure out how to pass parameters (values and functions) to an Angular directive. It seems like there should be a way to do this in Angular, but I haven't been able to locate the necessary information. Perhaps I'm not using th ...

Personalize the width of the columns

My SharePoint Online HTML code is as follows: <div sortable="" sortdisable="" filterdisable="" filterable="" filterdisablemessage="" name="Responsable" ctxnum="14" displayname="Responsable" fieldtype="User" ...

In the Twitter Bootstrap documentation, which element is utilized for the sidebar?

I'm curious about the most efficient method for creating a sidebar like this using Bootstrap 4. https://i.sstatic.net/3eKwN.png From what I can see, it appears to be a custom component designed specifically for the documentation page, rather than ...

Styling will_paginate Links in Rails 3 - A Guide

When it comes to coding layout, how should the link be styled? <a href="#" class="class1 class2 class3"><span>Previous</span></a> <a href="#" class="class1 class2 class3"><span>Next</span> In my search for a solu ...

Mastering the art of combining images and text harmoniously

I am having trouble aligning my lion image and h1 tag side by side. There seems to be an issue but I can't figure out what it is. h2 { width:50%; float:right; padding:30px 0px 0px 0px; margin:0 auto; } .lion { width:10%; float: left; paddin ...

How to position an absolute element beneath a fixed element

My website is experiencing a problem where the fixed header is overlapping an absolute paragraph on this page. Does anyone know how to resolve this issue? ...

How can I safeguard my HTML and CSS content from being altered using tools similar to Firebug?

Is there a method to deter the alteration of HTML and CSS components on a webpage using tools similar to Firebug? I have noticed that certain users are changing values in hidden fields and modifying content embedded within div or span tags for their perso ...

Troubleshooting problem with Angular Materials' md-datepicker not displaying correctly in wide browser windows

While using the md-datepicker component in my application, I noticed that it does not display properly on larger browser widths. It only seems to work as expected on small and x-small viewports. Please refer to the attached screenshot for reference. This ...

Strange occurrences of radio buttons in AngularJS

When working with radio buttons, I noticed a strange behavior that I wanted to share. My goal was to have Radio Button 1 selected if the array is undefined, and Radio Button 2 selected when the array is defined. In the initial state, the array is indeed ...

Is it possible to mix units within the 'path' element in SVG?

Utilizing SVG's rectangle element, you can specify dimensions as a percentage of its owner's dimensions and set a radius in pixels. By using the code below: <div style="position: relative;"> <object class="AIRound" t ...

The search function on my blog is not displaying the blogs that have been filtered

I have encountered an issue with my code as I am unable to get any search results from the search bar. const RecentBlogs = ({recentBlogs}) => { const [query, setQuery] = useState("") const filteredItems = (() => { if(!query) return rec ...

Looking to incorporate Slick Carousel as the main slider on my website for a dynamic hero section using JavaScript

Currently in the process of expanding my knowledge in javascript, I am now delving into setting up Slick Carousel. It is essential that it functions as a hero slider on my website. If you are interested in checking out Slick Carousel on github, feel free ...

Strategies for efficiently creating reusable HTML templates for recurring content blocks?

I am just starting out in web development and have encountered a problem with navigating through my page. The layout of the pages is the same, except for a div container. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3 ...

I'm interested in clicking on an image within a div to trigger a page refresh and then automatically hide the div once the page has refreshed

UPDATE 2 SITUATION To prevent access to quiz content until the page is refreshed, I am employing a semi-transparent image with a top-margin off-set. The following code functions flawlessly on one specific page and only once: JavaScript window.addEventL ...

Position text on the background image without using positioning techniques

I need to center my text precisely on top of my background image without resorting to the use of relative or absolute positioning. Many solutions online rely on using absolute positioning for the text along with a specified top value, but I prefer not to e ...

What is the best way to insert additional HTML elements beneath a video background that extends into the navigation bar?

*{ padding: 0; margin: 0; text-decoration: none; list-style: none; box-sizing: border-box; } body{ font-family: montserrat; } nav{ height: 85px; width: 100%; z-index:1001; } lab ...

Creating interactive HTML buttons using JavaScript to trigger AJAX requests

My current task involves populating an HTML table to showcase users. By making API calls to retrieve user data, I utilize Javascript to add rows to the table. Each row ends with a delete button, intended to trigger a $put request to a separate API endpoint ...

The hyperlink in the HTML code is malfunctioning

While working on a Wix website, I encountered an issue with the code snippet below: // JavaScript var countries = [ { name: 'Thailand', link: 'www.google.com' }, { name: 'Tanzania', link: '' }, { name: &ap ...

Retrieve all hyperlinks from HTML using C programming

Is there a way to extract all URLs from an HTML document using the C standard library? I attempted to use sscanf() for this purpose, but encountered errors when checking with valgrind. I'm unsure if my code will meet the requirements even after succe ...