Prevent my buttons from altering their color when hovered over

I have created some visually appealing buttons that I am satisfied with, but when a user clicks on one, the text color changes and the button's hover behavior is altered. I utilized this generator to design the buttons:

Below is the CSS code for my buttons:

.btn-custom-primary {
  // Button styling properties
}

Here is an example of how the button functions within a form using submit_tag:

<%= submit_tag 'Login', :class => "btn btn-custom-primary login-button" %>

And here is an instance of a problematic button:

<%= link_to "Sign up", new_user_path, :class => "btn btn-custom-primary signup-button" %>

The extra class added to each button is mainly for spacing purposes:

.login-button, .create-account-button, .signup-button {
  margin-left: 5px;
  float: left;
}

I've noticed that this issue occurs not only with previously clicked links, but also with all non-submit_tag buttons.

In addition, my navbar-collapse button exhibits similar behavior by changing to match the navbar color:

<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">

When hovering over a button that has already been clicked, it appears like this:

My desired appearance for the button during hover is as follows:

Answer №1

The hover effect you are observing is caused by the background-image styling added by Bootstrap to create a 3D-like appearance on buttons. To remove this effect, you can adjust the background-position property in the .btn-custom-primary class:

This effect is achieved by altering the position of the background-image, which can be eliminated by modifying the background-position attribute:

.btn-custom-primary {
    background-position: 0 center;
} 

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

Having difficulties adjusting the margin for a JSX element directly within the code

I'm struggling with giving a margin style inline to a JSX element. Here's the code snippet that I'm having trouble with: <Nunito20 style={{color: frenchGray, margin: 20 0 3 0;}}>Full Name</Nunito20> Unfortunately, this is throw ...

Is there a way to have the span update even if the input stays the same? Currently, it only changes when the input is different

Retrieve results of 3 lines (Ps) by entering a word in the text area and clicking search. If the word is found after clicking the button, a span will be displayed with the count of occurrences as well as the highlighted P(s) where it was found. If the wo ...

Ensuring that your content expands to fit the sidebar dimensions

I have diligently searched for a solution to my issue both on Google and here, but have yet to find one that works. I've experimented with various CSS properties like display: table-cell and inline-block, as well as different overflow options, but not ...

What is the best way to make today the default value on my datepicker?

How can I make my datepicker automatically default to today's date? $(document).ready(function() { $('.js-date').datepicker({ "setDate": new Date(), "autoclose": true }); }); <link href="https://cdnjs.cl ...

"HTML email design quandary: tackling a two-column layout

My attempts to create a two-column layout for a newsletter are leading to vertical alignment issues. Interestingly, some versions of Outlook display it correctly while others do not. Can anyone guide me on how to resolve this inconsistency? https://i.ssta ...

Replace the text in a different Div

Hello everyone, I'm struggling with an issue in my coding. Here is the HTML: <a href="aboutme.php"> <div class='aboutus'> <div id="mbubble"> stuff inside here </div> </div> ...

JQuery - Receive an error message when a value is missing

With my Website almost complete, I just need to add an error message for when a movie isn't found. I have an API that returns JSON and if someone enters an invalid movie like "ifeahaef," it returns null. Is there a way to use Jquery to display an erro ...

What is the best way to activate a scrollbar exclusively for the final section in fullpage.js?

Is there a way to enable a scrollbar for the last section only in fullpage.js? This is what I attempted: $("#section3").fullpage({ scrollBar: true, fitToSection: false, }); Unfortunately, it didn't work as expected. ...

Understanding the hierarchy of LESS css class structure is crucial for

In my chat contact list, each contact can have a different state represented by classes: .online .offline .online .selected .offline .selected Here are the corresponding styles (example): .online { background-color: #fff; p { color: #000; } } . ...

Center text vertically within a div using CSS

I need assistance with aligning my text vertically centered and left aligned to the logo in my HTML & CSS code. How can I achieve this with the code provided? Link to Fiddle: http://jsfiddle.net/z6yet59f/ .slogan { background:#eaeaea; float:lef ...

Text buttons on the menu are running into each other when displayed on an Android device

After recently completing a redesign of my website, hetoft.com, I am proud to say that I crafted the design and code entirely by hand, with only Dreamweaver as a helpful tool. This was my first experience creating a website with a CSS-based layout, and des ...

The CSS JSON code I have written is not having any impact on the appearance of my div

<!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="styles/common.css"> <script src="http://code.jquery.com/jquery-latest.min.js"></script> <script type='text/javascript'> ...

Ensure that the divs are properly aligned with the paragraphs

I received assistance previously, and I am seeking additional help in maintaining the position or adjusting the size of elements to fit different window viewport sizes such as tablets, mobile devices, or varying monitor sizes while keeping the appearance c ...

Preventing checkbox selection with CSS

Can CSS be used to deactivate clicks on checkboxes while still maintaining their functionality for dynamically setting values using Javascript? I have not been able to find a suitable solution. pointer-events:none Unfortunately, this did not work as expe ...

Trying to connect a webpage to my CSS file

Lately, I've been diving into building a new website. It's still in its early stages and unfortunately, I'm struggling to get the style.css file to cooperate. Despite my best efforts scouring the internet for fixes, I haven't had much l ...

Spinning divs using JavaScript when the mouse hovers over them, and then returning them to their original position when the mouse moves

I am looking to create a functionality where a div rotates when the mouse enters it and returns to its original position when the mouse leaves. Everything works fine when interacting with one div, but as soon as I try hovering over other divs, it starts gl ...

resizing a big image to perfectly fit the width of the screen with the help of

Is there a way to use AngularJS to automatically adjust the size of a large image to fit the screen on various devices (responsive), similar to how it is done on this website? Are there any Angular directives available for this purpose, or would I need to ...

Load the page before the images are displayed

Currently, I am utilzing Ruby threads with PhantomJS to convert multiple URLs into images. The issue is that the page only loads once all of the images have been generated. My goal is to implement a loading animation while the images are being created an ...

"Customizing the gaps between cluster bars on AmCharts JS for a clean and professional

Previously, I utilized the AmCharts flash version where creating clustered column/bar charts like the image below was a breeze. In that setup, the clustered bars were tightly packed with no spacing in between. However, transitioning to the JS version of Am ...

editing content within the same page in Rails 3

Exploring the realm of editing models in-place within the Show page offers a variety of options that eliminate the need to navigate to an Edit page. For some examples, check out . If you have any insight on utilizing these alternatives (or others) in Rail ...