Clicking the button will make it jump

I recently created a landing page for my BTEC Media coursework, but I encountered an issue with a button.

Whenever I click on my call-to-action button, it inexplicably increases in length. I've attempted adjusting the max-width to auto and tweaking margins, however, the problem persists.

Below are snippets of my CSS and HTML code:

HTML Code

<!-- Contact Button Bottom Right-->
<a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="335552585673565e525a5f1d505c5e">[email protected]</a>?subject=Envirma Education | Media Production Unit 6&body=To the attention of sir/madam,

Envirma Education | Media Production Unit 6" class="call-to-action">Click here to contact us! <i class="far fa-envelope-open"></i>
</a>
<!-- End of Contact Call-To-Action-->

CSS Code

/* Call to Action */
.call-to-action {
    background-color:#ffffff;
    border:1px solid #ffffff;
    -moz-border-radius:28px;
    -webkit-border-radius:28px;
    border-radius:28px;
    display:inline-block;
    font-size:17px;
    font-family: 'Roboto, Sans Serif';
    text-decoration:none;
    color:#000000;
    padding:16px 31px;
    position: absolute;
    display: block;
    right: 50px;
    bottom: 60px;   
    text-align: center;
}
​ .call-to-action a:hover {
    background-color:#C6DDF0;
    border:1px solid #C6DDF0;
}
.call-to-action a{
    text-decoration: none;
    color: #ffffff
}

.call-to-action:hover {
background-color:#C6DDF0;
}
.call-to-action:active {
position:relative;
top:1px;
}

Thank you for taking the time to read this. Any assistance is greatly appreciated. I understand that this might have a simple solution, but as a beginner in programming, I couldn't locate any resources online that address my specific issue.

Screenshot showing button width expansion upon clicking.

Answer №1

By removing the active anchor class, you will prevent your button from jumping to the top 1px. If you intended for the button to drop by 1px when clicked, consider increasing the margin-top by 1px:

.call-to-action {
  background-color: #ffffff;
  border: 1px solid #ffffff;
  -moz-border-radius: 28px;
  -webkit-border-radius: 28px;
  border-radius: 28px;
  display: inline-block;
  font-size: 17px;
  font-family: 'Roboto, Sans Serif';
  text-decoration: none;
  color: #000000;
  padding: 16px 31px;
  position: absolute;
  display: block;
  right: 50px;
  bottom: 60px;
  text-align: center;
}

​ .call-to-action a:hover {
  background-color: #C6DDF0;
  border: 1px solid #C6DDF0;
}

.call-to-action a {
  text-decoration: none;
  color: #ffffff
}

.call-to-action:hover {
  background-color: #C6DDF0;
}

.call-to-action:active {
  position: relative;
}
<a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fc9a9d9799bc99919d9590d29f9391">[email protected]</a>?subject=Envirma Education | Media Production Unit 6&body=To the attention of sir/madam,

Envirma Education | Media Production Unit 6" class="call-to-action">Click here to contact us! <i class="far fa-envelope-open"></i>
</a>

Answer №2

Eliminate the placement of the active anchor class.

.call-to-action:active {
    position:relative;
    }

Answer №3

element, an anchor was removed and the top tag was eliminated because it caused movement upon being clicked or activated.
.call-to-action:active {
  position: relative;
}

Credit goes to MichaelvE for providing the solution.

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

Display a picture from a directory onto a webpage by incorporating ASP.NET in C#

I am in the process of creating an image gallery for my website. In this scenario, I am displaying thumbnails of all images and when clicked, the image appears in a modal window. There are two main folders: Thumbs (contains thumbnails) Full Image (contai ...

CSS shapes are extending beyond the boundaries of their parent container

I'm working on a small webpage and I am trying to incorporate 2 shapes in the background (see design screenshot attached). Using CSS, I created these shapes but I am facing an issue where the bottom right shape keeps extending beyond the container, ca ...

What is the most efficient method for updating URLs in CSS files before the website goes live?

The project I am currently working on has been worked on by various coders with different backgrounds. One of my recent achievements was writing a clean Capistrano recipe to minimize CSS and JS files. Now, the challenge ahead is figuring out how to identif ...

Explore the possibilities with Intel XDK's customizable keyboard feature

I recently started using Intel XDK for development and I encountered the following issue: I have an input text field (HTML) and I need to restrict user input to only numbers, decimals, and negative sign when they click on the field. How can I achieve this ...

If a <section> element contains a <header>, must it also include a <footer>?

Here is the current state of my code: <section id="one"> <h2>Section Title</h2> <p>Lorem ipsum...</p> <p>Lorem ipsum...</p> <p>Lorem ipsum...</p> </section> <section id="two"&g ...

Using Javascript to populate textboxes with the value of checkboxes

Within my web application, there is a series of checkboxes that, when selected, populate a textbox located above them. If more than one checkbox is checked, their values are displayed in the textbox separated by commas. These checkboxes are structured as ...

Using jQuery, how can I dynamically change the stacking order of an element when clicked?

I'm struggling to change the z-Index on button click. I have a static image and a dynamic div, and I want to send the #imgDiv1 behind the static image. Unfortunately, despite trying everything, I haven't been able to achieve this. You can check ...

Email contact form using PHP

After following a tutorial on creating a basic 'contact us' form using PHP, I want the form to display a thank you message or error message directly on the same page instead of redirecting to a separate thank you page. How can I modify the code ...

Challenges with resizing in Bootstrap

I need assistance with my login form that is appearing in a Bootstrap modal. The modal I am using is the standard size, not the larger one. In the form, there are 2 input fields and a login button on the left side, while the right side should contain other ...

HTML and CSS display differently on Internet Explorer browsers

Why is the code displayed differently in IE11, showing up on two lines for some reason? The code has been simplified for display purposes here, which may make it look odd visually. HTML <ul class="nav navSilver" style="border: 1px solid green;"> ...

The background on my modal remains unchanged

I have integrated a modal using Iframe for user login/registration on my website. Here is the HTML code: <div class="modal" id="ays-popin-connexion" aria-hidden="true"> <div class="modal-body" aria-hidden="true"> <iframe src=" ...

Issues with jQuery scroll effect not functioning properly in Firefox due to transformation errors

I've encountered an issue with implementing a scroll effect in Firefox. The code works perfectly fine in Chrome, Safari, and Opera, but for some reason, it's not functioning properly in Firefox. I have carefully reviewed the '-moz-transform& ...

Unable to ensure uniform height for React MUI Cards

I am facing a challenge with my dashboard layout that consists of 3 cards, each containing a separate component. The height of the cards dynamically adjusts based on their content. My goal is to make all 3 cards have the same height as the one with the t ...

Scheduled Events and revising the date navigation in the calendar

https://developer.mozilla.org/fy-NL/demos/detail/html5-calendar/launch Among the codes provided, which specific code enables the use of the browser's back/forward buttons to change the day? I'm having trouble figuring it out. Additionally, do y ...

What is the best combination of tools to use for web development: express with jade/ejs, along with html5, css

As I delve into learning node.js/express, a question arises about how jade/ejs, html, and css work in harmony. Allow me to share my understanding: The application logic is implemented in node.js/express A portion of this logic/variables is injected into ...

Using clearfix on every div element is essential to avoid container collapsing

Would it be beneficial to include clearfix in every div element to avoid container collapse issues? Or is it more practical to apply it only to specific classes, like so? <div class="container"> Additional div elements... </div> .containe ...

Content in Bootstrap not filling entire mobile screen

The content in this form does not stretch to full screen on mobile phones, but it appears properly on computers and tablets. Please advise on how to solve this issue. https://i.stack.imgur.com/S2XkS.jpg <link rel="stylesheet" href="https://maxcdn.bo ...

What is the best way to ensure my header element is positioned above my h2 element on the webpage?

<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script> <div id="page-wrapper"> <header id="header"> Hoppity Edits <div class="logo"> <im ...

The issue with the smooth scrolling feature in next/link has not been resolved

I am currently facing an issue where smooth scrolling is not working when using next/Link, but it works perfectly fine with anchor tags. However, the downside of using anchor tags is that the page reloads each time, whereas next/link does not reload the pa ...

The <h1> element is not responding to the style attribute

Exploring HTML as a beginner has led me to an interesting issue. I've been practicing my newfound skills on W3Schools' platform and everything was running smoothly until I encountered a discrepancy in how the code is rendered on Wordpress. The s ...