Pressing the form submit button causes it to shift its position

Encountering an issue with the submit button on a simple form. Upon clicking, the button moves unexpectedly in Firefox, shifting up slightly by a few pixels. The webpage can be accessed at . Any suggestions on how to resolve this problem?

HTML

<form id="form" method="post" action="http://example.com/processform/">
<p>Name</p>
    <input type="text" name="name"/>
<p>Email Address</p>
    <input type="text" name="email"/>
<p>Message</p>
    <textarea name="comments" rows="15" cols="38"></textarea></p>
<p></p>
<input class="button" value="Send" type="submit"/>
</form> 

CSS

#form {
font-size: .8em;
margin: 0 auto;
padding: 10px 0px 40px 25px;
width: 385px;
height: 400px;
position: absolute;
top: 190px;
left: 290px;
box-shadow: -4px -6px 8px 2px rgba(225,229,232,.5),
            8px 6px 12px rgba(225,229,232,.5);
}
#form p {
padding: 15px 0 5px 0;
}
.button {
-moz-box-shadow:inset 0px 1px 0px 0px #bbdaf7;
-webkit-box-shadow:inset 0px 1px 0px 0px #bbdaf7;
box-shadow:inset 0px 1px 0px 0px #bbdaf7;
background:-webkit-gradient( linear, left top, left bottom, 
    color-stop(0.05,    #79bbff) color-stop(1, #378de5) );
background:-moz-linear-gradient( center top, #79bbff 5%, #378de5 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#79bbff',    endColorstr='#378de5');
background-color:#79bbff;
-moz-border-radius:6px;
-webkit-border-radius:6px; 
border:1px solid #84bbf3;
display:inline-block;
color:#ffffff;
font-family:Arial;
font-size:15px;
font-weight:bold;
padding:6px 24px;
text-decoration:none;
text-shadow:1px 1px 0px #528ecc;
position: absolute;
top: 470px;
left: 2px;
}
.button:hover {
background:-webkit-gradient( linear, left top, left bottom, 
    color-stop(0.05,  #378de5), color-stop(1, #79bbff) );
background:-moz-linear-gradient( center top, #378de5 5%, #79bbff 100% );
filter:progid:DXImageTransform.Microsoft.gradient
   (startColorstr='#378de5', endColorstr='#79bbff');
background-color:#378de5;
}
.button:active {
position:relative;
top:1px;
}

Answer №1

An issue arises when the .button is absolutely positioned in its non-hover state.

Upon hovering over the button, its positioning changes to relative, leading to a drastic shift in its location.

To resolve this issue, simply delete the following lines of code:

.button:active {
   position:relative;
   top:1px;
 }

Note:

Interestingly enough, it took longer to document this problem than it did to find 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

Is it possible to create HTML tables without including paragraphs within the cells using docutils rst2html?

If my input rst file looks like this: +--------------------------------+ | Table H1 | +-------------+------------------+ | Table H2a | Table H2b | +=============+==================+ | a1 | b1 | +------ ...

Set a consistent pixel measurement for all images

I am working on a project where I have an image of a card that needs to be repeated 30 times. Each time the card is repeated, I want it to overlap with the previous card in a specific position, resembling a deck of cards. The issue I am facing is that whe ...

I attempted to create an image using the open ai api from delle, but encountered an error in the process

Snippet: import { useState } from "react"; import axios from "axios"; function App() { const [prompt, setPrompt] = useState(""); const [result, setResult] = useState(null); // Starting result as null const [ ...

Injecting PHP variables into CSS code right from a PHP file

$a = "ABCD"; ?> <link rel='stylesheet' type='text/css' href='others.php' /> <style> .page-title { text-indent: -9999px; line-height: 0; } .page-title:afte ...

"Using the CSS :nth-of-type selector in a for loop does not pull out the

I am looking to extract the strings text_i_wantA, text_i_wantB, and text_i_wantC from each of the 3 children within each of the 10 div class = col-12. To enhance readability, I have only included two similarly structured divs here. If the output does not c ...

IE8 - Unable to use rgba()

I'm currently facing an issue with RGBA() manipulation in jQuery while using IE 8. Here's the code I have so far: $('.set').click(function (e) { var hiddenSection = $('div.hidden'); hiddenSection.fadeIn() . ...

What are the top techniques for designing with Angular 2 Material Design?

As a newcomer to angular 2 material design, I have noticed the primary, accent, and warn classes that apply specific colors to elements. Are these the only styling options available in Angular Material 2? Are there other classes that can be utilized for cu ...

What is the best way to break down a BeautifulSoup Tag replica found in the original HTML code?

I am facing a challenge with removing an element from the source BeautifulSoup object using my element extractor. For example: def extract_element(soup: bs4.BeautifulSoup) -> bs4.Tag: tag = soup.select('my-css-selector-or-something-else' ...

angular use ngFor directive to restrict the number of rows displayed in a table

In my angular 6 project, I am trying to limit the display to just five rows in a table using ngFor. My current code snippet is as follows: <tbody> <tr *ngFor="let item of routines; let i = index"> <td style="display: none"> ...

JavaScript encoding the text

Looking for a straightforward JavaScript function to encrypt text data from a textarea using a key (the key being the user's password stored as a hashed session variable, outputted by PHP into a field). The objective is to have the content of the tex ...

The image is not displaying on the button

When using 3 buttons in my extjs script, I noticed a strange issue where the buttons were not visible on the page. Upon inspecting the elements using firebug, here is what I found: <button id="button-1051-btnEl" class="x-btn-center" autocomplete="off" ...

Insert the characteristics of the object into the header of the table, and populate the rows of the table

I have created an HTML table that displays specific object properties when the mouse hovers over a designated object. For example, hovering over the dog object will display the dog's name. I want to expand this functionality to also show the cat' ...

Combining jQuery form validation with a PHP script on a single webpage

After implementing jQuery form validation and redirecting using the function btn_onclick() { window.location.href = "http://localhost/loginprivate.php";} from index.php to loginprivate.php, my web app's PHP script is not being executed. The user is re ...

How come the dropdown menu consistently disrupts my CSS design?

Whenever I add a dropdown menu, my CSS layout gets all messed up. Can someone please explain why this happens and how to fix it? Below is the code snippet: <asp:Label ID="projnamelbl" runat="server" CssClass="editlabels" Text="Project Name"></as ...

Tips for Excluding Content Retrieved Through file_get_contents?

Currently, I am storing the source code of a webpage in a variable called $html using the following line: $html = file_get_contents('http://www.google.com'); When I use <textarea><?php echo htmlentities($html); ?></textarea> ...

Tips for creating a webpage with a spotlight effect using the mouse cursor

My goal is to create a webpage that is completely dark (as in night without any light at all) and have the mouse cursor emit a light effect to illuminate the surroundings. What tools or techniques should I use to achieve this unique effect? I've searc ...

The CSS menu dropdown fails to function properly on desktop view when there is longer content present

I attempted to merge two different navigation bars, one sticky and the other responsive. The goal was to combine https://www.w3schools.com/howto/howto_js_navbar_sticky.asp with https://www.w3schools.com/howto/howto_js_responsive_navbar_dropdown.asp Curr ...

What is the best way to display a particular JavaScript variable in an HTML document?

Is there a way to display the value of a Javascript variable in an HTML form, such as showing it on the screen? Below is my JavaScript code: <script type="text/javascript"> var howLongIsThis = myPlayer.duration(); </script> The variable howL ...

Tips on implementing taxonomy-driven CSS styling with Drupal's template.php file?

Currently, I am excited about incorporating CSS styling based on taxonomy terms, particularly for the body tag where I aim to include the current terms. Here is my progress so far : function _phptemplate_variables($hook, $vars = array()) { global $no ...

two clicks on the sc-player

I've encountered a problem of duplicated events when using sc-player.js. I'm trying to change an iframe when a li element is clicked, but the play/pause buttons also trigger the same li click event. Is there a way to control the play/pause funct ...