Navigating the shift from HEX to gradient in CSS

Is there a way to smoothly transition the background from a HEX color to a gradient and back?

I've set my variable --base as white, but the transition between HEX and gradient isn't working.

:root {
  --app: radial-gradient( circle 753.6px at 10% 20%, rgba(248,167,221,1) 0%, rgba(230,192,254,1) 41%, rgba(169,217,243,1) 90% );
  --base: #FFFFFF; /* radial-gradient(#FFFFFF, #FFFFFF) */
}

body {
  background: #DDD;
}

div {
  height: 100px;
  line-height: 100px;
  text-align: center;
  width: 300px;
  background: var(--base);
  transition: all 1s ease;
}
div:hover {
  background: var(--app);
}
<div>test</div>

Even when I try changing --base to radial-gradient(#FFFFFF, #FFFFFF), it still doesn't work. Does anyone have a solution for this issue?

JSFiddle

Answer №1

I have devised a solution tailored just for you: https://jsfiddle.net/axgq60ro/4/ To achieve a smooth transition between these elements, employing the z-index trick is essential. For more details, I recommend going through this insightful article: Wishing you a wonderful day!

div:hover::before {
   opacity: 1;
}

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

Activate a flash by pressing a button

I'm currently working on my school project, a website called dreamfoxgames.com. When you click on the "play" button, a popup/modal will appear with either a flash or unity plugin game. My concern is that when a visitor lands on the page, the flash fi ...

Deselect a checkbox by selecting a radio button with just Javascript code

Hey there! I'm currently delving into the world of pure JavaScript and could really use some guidance on a particular issue. Here's what I'm aiming to accomplish: I'd like to design a checkbox that triggers the opening of a window whe ...

The results in the grid are displayed in a horizontal layout, rather than a

My grid results are not rendering as desired, appearing horizontally instead of in two columns. Attached is my current CSS and a screenshot of the issue for reference. Any suggestions on how I can achieve the layout shown in the screenshot below? .grid ...

Including tabs from a different HTML page within a tab on my own HTML page - enhancing the user interface of a web application

I am currently developing a web application with 4 tabs. Each tab includes a side menu (created using jQuery) and the rest of the space is divided into two sections: top div and bottom div (a table with two columns - column 1 contains the side menu, and co ...

Alignment issue: table-cell elements are not lining up correctly

Curious as to why the containers on this page seem misaligned. Any assistance would be greatly appreciated. Thank you. http://codepen.io/anon/pen/jpmtz ...

My lists are not being styled by Embedded and Internal CSS

I want the ingredients list to be styled in green, equipment list in red, and method list in blue using different CSS techniques. My external works fine for changing the color to red, but my internal styles don't seem to apply to the other lists. < ...

What is the best way to halt my jQuery animation?

(function ($) { $(document).ready(function () { $('#road').pan({ fps: 30, speed: 9 }); $('#city2').pan({ fps: 30, speed: 2 }); $('#city3').pan({ fps: 30, speed: 5 }); $('#sky') ...

Shimmering CSS Animation in iOS Versions 13 and below

Have you ever noticed a strange "blinking" effect when layering multiple CSS rotation keyframe animations on top of each other? Check out this Codepen example to see it in action: https://codepen.io/JoshuaVB/full/bGevLbR. @keyframes waves{ 0%{ transf ...

Ways to align text in a table row in a way that it remains positioned at the center of the screen's visible area

Can anyone assist me with this task? I need help centering text within a table row ('Some text here...') so that it always appears in the middle of the screen. The table will have horizontal scrolling. .compare-content { max-width: 480px; ...

Tips for Modifying CSS Design for Unhovered Elements

HTML <ul id="menu"> <li><a href="#">Home</a></li> <li><a href="#">Categories</a> <ul> <li><a href="#">1</a></li> < ...

Is there a way to make all DIVs in the same class have the same height as the tallest div?

I have 3 identical divs with an auto height value. How can I set the height of all divs in the same class to be equal to the highest div's height? Same Class Div Thank you in advance. ...

Tips for utilizing the two-function in jQuery to showcase one DIV following another DIVNote: When using the two-function

Apologies in advance for my poor English skills, but I have been contemplating whether to write here and if you will be able to understand me. I am currently working on a jQuery script: $(function() { $('#div1').hover(function() { $ ...

Tips for rearranging button placements by utilizing multiple owl carousels across various webpages

I have successfully implemented two owl carousels on my Shopify website, and they are both functioning properly. However, I am facing an issue with the navigation buttons on the second page. The navigation buttons seem to be picking up a style that I had i ...

Tips for dividing a div into percentages while maintaining a constant width for a div on the left side

I need help with creating a layout that involves 4 boxes. The first box (box1) should have a width of 50px on the left side, while the remaining 3 boxes should fill in the rest of the screen and be resizable. Can someone guide me on achieving this layout? ...

Desktop users will not see the mobile navigation bar

I'm working on creating a sidebar navigation that stays fixed on desktop but collapses on mobile devices. The issue I'm facing is that once I toggle the navigation on mobile, it remains toggled and doesn't show up on desktop. Check out my co ...

jQuery show/hide functionality allows you to toggle the visibility of elements

I am looking to create a toggle button that expands the menu-wrapper width and hides the sidebar when clicked. Here is the initial CSS styling: #my-wrapper { Width:500px; } #sidebar-wrapper { width:200px; } Upon clicking the button, the CSS will update ...

Troubleshooting the Owl carousel's responsiveness with a div width of 1170px

Whenever my display size is less than 1170px, the width of the owl carousel div overflows. How can I fix this issue? jQuery(document).ready(function($) { "use strict"; // CUSTOMERS TESTIMONIALS CAROUSEL $('#customers-testimonials&a ...

Is there a way to ensure that HTML5 audio is responsive when using Bootstrap?

I need help with making my HTML5 audio player responsive in Bootstrap. Here is the code I currently have: <div class="col-sm-4 col-sm-offset-4"> <audio controls style="width: 600px;"> <source src="sample.mp3"> < ...

Positioning custom buttons using CSS and HTML

Need help with centering a button inside a div within a table cell. Is there a way to determine the current size of the hovered-over div and position the button in the middle both vertically and horizontally? https://i.sstatic.net/6NQ9J.jpg I hope you ...

What is the best way to create a strip within an oval using CSS to achieve a partially filled vertical vessel effect?

I need to create an oval shape with a strip inside to represent the level of liquid volume. Here is my initial attempt: <style scoped> .strip:before { position: absolute; background: #343434; border-bottom: 2px solid black; content: ""; ...