Is it possible to insert a link into a CSS button while ensuring that the button's transition effects are visible before proceeding to the next page?

Is there a way to include a link in this CSS button without interfering with the transition effects? Here's an example I found on Google: Visit http://www.w3schools.com/css/tryit.asp?filename=trycss_buttons_animate2

Answer №1

Give this a shot with setTimeout():

$(function() {
  $('a').click(function(e) {
    e.preventDefault();
    setTimeout(function() {
      window.location = $(this).attr('href')
    }, 200);
  });
});
.button {
  position: relative;
  background-color: #4CAF50;
  border: none;
  font-size: 28px;
  color: #FFFFFF;
  padding: 20px;
  width: 200px;
  text-align: center;
  -webkit-transition-duration: 0.4s;
  /* Safari */
  transition-duration: 0.4s;
  text-decoration: none;
  overflow: hidden;
  cursor: pointer;
}
.button:after {
  content: "";
  background: #90EE90;
  display: block;
  position: absolute;
  padding-top: 300%;
  padding-left: 350%;
  margin-left: -20px!important;
  margin-top: -120%;
  opacity: 0;
  transition: all 0.8s
}
.button:active:after {
  padding: 0;
  margin: 0;
  opacity: 1;
  transition: 0s
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="http://google.ro">
  <button class="button">Click Me</button>
</a>

Answer №2

To create a clickable button, enclose it within an <a> tag and specify an href attribute that points to the desired link.

Answer №3

Implement the onclick function within your button tag to execute a specific action. Here's an example:

<button class="button" onclick="location.href='http://google.com';">Click Me</button>

This method will not interfere with any transition effects applied to the button.

Answer №4

If you need to perform a task after a certain delay, consider using setTimeout() method.

onclick="setTimeout(function(){window.open('http://www.google.com')},500)

In the provided code snippet, simply replace '500' with your desired transition duration.

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

What criteria does a PHP function need to meet in order to be considered valid for use with AJAX and PHP?

My website includes an input field that undergoes real-time checking via AJAX requests to inform users if their input is valid or not. Upon submission, the input must be rechecked to ensure it meets the same criteria as checked by AJAX (in case JavaScript ...

Siblings mousedown event propagation

In my HTML code, I have a division that contains multiple image objects with the position set to absolute. Here is an example: <div> <img> <img> <img> <img> </div> The problem arises when the ...

Design a gradient backdrop resembling a duo of bars for a visually appealing effect

Looking to create a unique background effect that resembles two progress bars as shown in this image: https://i.sstatic.net/LpENZ.png I know how to create one progress bar using linear gradients, but I'm wondering if there's a way to split the b ...

"Step-by-step guide on triggering the ng-click function for the first row within an ng

I'm facing an issue where the first set of data from the ng-repeat div is not loading before clicking on the ng-repeat. Below is the code snippet: <div class"profile" ng-repeat="data in information" ng-click="getData(data.i ...

Is it possible to fill dropdown menus on a webpage using jQuery or JavaScript without the need for an ajax call?

Currently, I am looking to populate multiple dropdown lists using jQuery when the page loads rather than relying on ajax responses to events. My Controller is responsible for creating several List objects that will be used for these dropdowns. Right now, I ...

Customizing the jQuery Datepicker to only allow a predefined set of dates

I am looking for assistance regarding the jQuery datepicker. I have an array of dates and I need to disable all dates except for the ones in this specific array. Currently, the code I have does the opposite of what I need. I generate the array of dates in ...

How to eliminate the bottom border in react-native-material-dropdown

I recently integrated react-native-material-dropdown-v2 into my project using React Native. https://i.sstatic.net/aKVfi.png Is there a way to eliminate the bottom border in this material dropdown component? My React Native version is 0.62.2. ...

The variability of jQuery values

I have created a website control with jQuery that features a long bar consisting of four colored divs. Users have the ability to drag the join between two divs in order to resize it, all within the confines of the bar itself (keeping the overall width of t ...

Secondary navigation bar remains hidden

I am facing an issue with the sub menu bar on this website. I am using the Constellation theme for WordPress and have attempted to adjust margins in order to make it visible, but so far I have been unsuccessful. The sub menu is meant to be responsive, yet ...

Selenium Webdriver is retrieving background colors with unexpected alpha values

When I need to retrieve the background-color of a WebElement, I typically use the following code: string color = IWebElement.GetCssValue("background-color"); Selenium often returns something like this for the color value: color = "rgba(153, 255, 255, 1) ...

Is there a way to reduce the spacing between these child containers when they wrap?

I'm looking to reduce the space between my child divs when they wrap It seems like the issue lies within the media query * { margin: 0; padding: 0; box-sizing: border-box; } html { font-size: 10px; width: 100%; } html, bo ...

Update the div on the current page using externally retrieved information

Once again, I find myself stuck on a problem. Allow me to explain. Within this div, I have retrieved data using HTML SIMPLE DOM from another site. Like so: <div id="data">.....</div> Currently, the data refreshes whenever the user reloads th ...

Scroll left to erase using PhoneGap

After following a tutorial that resulted in creating a web app to store form input data locally, I attempted to create a native app using phonegap and Xcode. However, I am struggling to figure out how to implement a swipe to delete feature for individual ...

Submitting a form with dynamic columns and rows can be achieved by carefully designing the form to

Below is the form structure: <table id="participants" class="table table-bordered table-hover table-responsive text-center"> <form action="unique-controller.php" method="post" id="uniqueForm" enctype="multipart/form-data"> <input type="hidd ...

issue with knockoutjs html binding

I'm attempting to utilize the html binding feature to link some html code to a label element, in order for the label to display the specified text. Despite using the html binding, the label remains blank. However, upon inspecting the page in the brow ...

CSS styling does not apply to HTML elements that are dynamically created using JavaScript

A script containing dynamic HTML content is sourced from an external website, injected by RSS feeds. To access the content directly, visit this link. The script needs to be wrapped around HTML tags for front-end display. For example: <div>http://fe ...

Reduce the width of a div using Bootstrap

I am looking to adjust the width of the black background to match the image and buttons for better proportions. Below is the code for one component on the page, with a similar structure for other components as well. <link rel="stylesheet" href="http ...

Display Toggle button, provided that there is a selection in at least one checkbox

My goal is to have the buttons "btns" remain visible if one or more checkboxes are checked, and hide them only when all checkboxes are unchecked. Currently, the buttons show up when I check a checkbox, and disappear when I uncheck it. How can I modify my ...

Remove the div containing the image from the server using the data-id parameter via ajax request

Currently, I am working with WordPress and in need of a script to remove images from the gallery. The current script I have deletes images only from the page and not from the server. This means that if I save changes and reload the page, the images will st ...

The Safari extension is launching as a file within Safari browser version 5 on a Mac running the Snow Leopard operating system

I recently ventured into the world of Safari extension development. After creating an extension using Extension Builder, I packaged and uploaded it to a server. On my website, I provided a download link for the extension: <a href="http://example.com/ex ...