Using jQuery to animate the border radius on elements

Having trouble animating the style border-top-left-radius. I am currently using two length values entered separately like this.

border-top-left-radius: 15px 25px;

I want to be able to increase each of these values individually using jquery.animate().

Is there a way to do this?

Answer №1

Is it true that border-top-left-radius only accepts one value? In that case, you can animate it like this:

$('.class').animate({borderTopLeftRadius: 20})

UPDATE


I'm not sure if jQuery natively supports this. You might need to implement the step callback like so:

$('#container').animate({
    borderTopLeftRadiusSideLength: 500,
    borderTopLeftRadiusUpperLength: 50
}, {
    duration: 5000,
    step: function (val, context) {
        $(this).data(context.prop, val);
        var side = $(this).data('borderTopLeftRadiusSideLength');
        var upper = $(this).data('borderTopLeftRadiusUpperLength');
        if (side && upper) {
            $(this).css('borderTopLeftRadius', side + 'px ' + upper + 'px');
        }
    }
});

Check out this jsFiddle link for more details.

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

multiple elements sharing identical CSS styling

For each component, I made separate CSS files and imported them accordingly. However, despite the individual styling efforts, all components seem to have the same appearance. I specifically worked on styling an image differently for two components, but w ...

Building collapsible table cell components using ReactJS and Bootstrap 4

For each table row, I need to implement a feature that allows users to click on it and view specific information related to that row. After doing some research, I came across this thread: Twitter Bootstrap Use collapse.js on table cells [Almost Done] I ma ...

Center the content within bootstrap-cards

Looking at the image, it's clear that the last line of text is not on the same alignment as the other bootstrap-cards. This seems to be influenced by the length of the upper text. How can I make sure that all three main parts are always aligned, rega ...

The background image in CSS refuses to display

My CSS background image isn't displaying properly. Here is the code snippet from my HTML: <div class="container-fluid p-c b-g"> <div class="row"> <div class="col-sm-12 text-infom"> </div> </div> </ ...

Utilizing MVC4 and jQuery: Seamlessly navigating to a different view with the click of a button, while simultaneously transmitting a parameter object to the destination

As a newcomer to MVC4, I am currently learning and developing an application simultaneously. Within this application, there is an "index.cshtml" view that contains a "fresh" span (button). When this button is clicked, I intend to: Redirect to another vie ...

Alpinejs Mega Menu Issue: Hover Functionality Glitchy

I'm working on a complex Mega Menu project that is activated upon hovering, using the powerful combination of Tailwind CSS and Alpinejs. The functionality is mostly there, but I've encountered some bugs along the way. Despite my attempts to impl ...

Navigating dynamic forms in symfony - a comprehensive guide

How can I successfully print a form sent via ajax? ajaxControllerAction(){ $form = $this->createFormBuilder() ->add('date', 'date') ->add('text', 'text') -> ...

Adding a prefix to the imported CSS file

My React app, created with create-react-app, is designed to be integrated as a "widget" within other websites rather than functioning as a standalone application. To achieve this, I provide website owners with minified JS and CSS files that they can inser ...

The Navbar design in Bootstrap is not scaling properly with the background image, making

I am currently in the process of developing a Bootstrap 5 webpage based on a provided design, but I am encountering some challenges. Here is the design I am working from: https://i.sstatic.net/MsFzq.jpg Here is my current progress: https://i.sstatic.ne ...

What causes the CSS `resize` property to be inherited in Chrome browsers?

It was my understanding that elements do not inherit the resize property from their parent elements. However, I recently discovered that in Chromium they actually do: Here is a screenshot of Chromium's inspector: Check out this demo: http://jsfi ...

Photos on Display are Misaligned

I'm currently in the process of developing a responsive photo gallery based on this tutorial. Within my project, there exists a component known as MemoryList which is defined as shown below: import React from 'react'; import _ from 'lo ...

Guide to obtaining multiple arrays and updating the values of their respective array keys with jQuery

Here is a sample image of the output. I am trying to implement a feature where changing the quantity in a column will automatically update the total price associated with it. I am attempting to achieve this using jQuery, but I have encountered some challen ...

Preventing touchstart default behavior in JavaScript on iOS without disrupting scrolling functionality

Currently experimenting with JavaScript and jQuery within a UIWebView on iOS. I've implemented some javascript event handlers to detect a touch-and-hold action in order to display a message when an image is tapped for a certain duration: $(document) ...

Is there a way to make those three elements line up in a row side by side?

I'm working on a layout using HTML and CSS that will display two images on the left and right sides of the browser window, with text in between them. I want them all to be horizontally aligned within a container. Here is the code snippet: <div cla ...

Having Trouble Parsing JSON Object with JQuery?

I'm having trouble extracting data from a valid JSON object using jQuery/JavaScript - it always returns as 'undefined'. var json = (the string below). var obj = $.parseJSON(JSON.stringify(JSON.stringify(json))); alert(obj); // aler ...

What method does the CSS standard dictate for measuring the width of an element?

In terms of measuring an element's width, Chrome appears to calculate it from the inner margin inclusive of padding. On the other hand, Firefox and IE determine the width of the box from the border, excluding padding but including the margin. Personal ...

What is the best way to position a Button at the bottom of a div using jQuery?

Within my HTML, I have divided into two col-md-6 sections. On the left side, there is a picture and on the right side, there is text. I am considering using jQuery .height() for this layout. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7 ...

After a few ajax requests in jQuery, the functions live(), delegate(), and on() may no longer function properly

I've set up html elements with the class "ajaxem" to be used in my jQuery code below. The same goes for form elements. Initially, everything works fine - the jQuery is attached and triggered properly for the first few ajax requests. However, once a us ...

Custom CSS file for individual tenants in the Twig main template

Our Symfony 2.4 application is a multi-tenant system, meaning we share the same codebase among several organizations and differentiate access by domain name. For example: organization1.domain.com organization2.domain.com organization3.domain.com We util ...

Slide out a div when hovering over a button

Currently in the process of learning jQuery, I have managed to create a button that toggles a div containing colored buttons when clicked: https://i.sstatic.net/VNxym.png Once these colored buttons are pressed, the main white button changes color based o ...