Tips on maintaining the functionality of the :hover selector even after loading a PDF document

Recently, I noticed an issue with an anchor element that is used to load a PDF. Once the PDF loads, the :hover styling seems to get stuck until I click elsewhere on the screen, which then resets it back to normal. Surprisingly, there is no JavaScript involved and the only relevant CSS code is as follows:

.my-btn {
    color: #3568c4;
    background-color: transparent;
    border-color: #3568c4;
}

.my-btn:hover {
    background-color: #3568c4;
    color:white;
}

Answer №1

It seems like the default settings of your browser are causing some issues, consider resetting them or using custom classes to override them

The order of pseudo-classes in CSS is important for their effectiveness - a:hover MUST come after a:link and a:visited!

Similarly, a:active MUST come after a:hover in the CSS definition to work correctly!

Remember that pseudo-class names are not case-sensitive.

.my-btn,
.my-btn:visited {
  color: #3568c4;
  background-color: transparent;
  border-color: #3568c4;
}

.my-btn:hover {
  background-color: #3568c4;
  color: white;
}

.my-btn:active {
  color: #3568c4;
  background-color: transparent;
  border-color: #3568c4;
}
<p>Note: a:hover MUST come after a:link and a:visited in the CSS definition to be effective!</p>
<p>a:active MUST come after a:hover in the CSS definition for it to be effective! </p>
<p>Pseudo-class names are not case-sensitive.</p>
<button class="my-btn">Test</button>

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

Styling Vuetify components such as v-textarea using custom CSS for a unique design

Is there a way to style the underlying html textarea of a vuetify v-textarea using CSS? I'm trying to customize the line height, font family, color, and more of the v-textarea component. Simply adding a class to it doesn't seem to work: <v-tex ...

Is it possible to terminate an active server process triggered by an HTTP post request in Node.js prior to returning a response?

I developed an application where I utilized Ajax to make calls to a Node server. The issue is that even if the user navigates to another page, the server persists in processing the initial request made by the Ajax call. It then proceeds to process the new ...

Using JSON data with PHP, MySQL, and jQuery

I'm encountering an unusual issue. Whenever I try to access my JSON code with the corresponding numbers [0], [1], etc., I only get the first character of the object. Here's a snippet of my code: test2.php if(isset($_POST['getCustomersArr ...

Utilize JavaScript to parse HTML content retrieved through AJAX requests

My current project involves writing JavaScript code, specifically a Chrome extension, that needs to: Retrieve the contents of a web page using AJAX. Extract specific content from the page by identifying certain elements within the HTML string and retriev ...

Change this time record into a standard date

"usage_timestamp": [13308678945000000] I am trying to convert this unique timestamp format found in my JSON file into a normal date using Node.js. Can anyone help me with the proper conversion process? It seems like this is not your typical Uni ...

Vue 3: `defineProps` allows components to locally reference declared variables

Why am I receiving a warning error message: defineProps is referencing locally declared variables. eslint(vue/valid-define-props) whenever I utilize a custom validator in props within an SFC <script setup> mode: <script setup> import { valid ...

Use jQueryTOOLS to dynamically adjust the position of tool tips based on the class of their trigger

I am currently implementing tooltips on my website using the jqueryTOOLS plugin for jquery. The tooltips are generated for a set of form fields. To trigger the tooltip event, I am using the following block of javascript: $(function() { $("#myform :input[ ...

How can a variable that is potentially undefined be converted to lowercase in Node.js?

My latest project involves developing a discord.js bot with commands that can take different parameters like mc!start vanilla, mc!start tekkit. However, the bot is designed to handle only singular string entries. So, when a user inputs just mc!start with ...

Issues with positioning images using media queries

Can anyone help me center an img when the viewport width is 320px? I've attempted different approaches but so far, nothing has been successful. .logo { width: 55px; height: 55px; margin: 10px 0 10px 30px; float: left; } @media only screen a ...

jQuery UI Autocomplete for web addresses

I am trying to implement instant search with jQuery UI autocomplete, and I want to be able to add a link that will be triggered when a result is clicked. Javascript $("#searchinput").autocomplete({ source: "search/get_searchdata", select:function ...

IE is failing to trigger jAlert function

When I validate a text box by pressing the enter key on my keyboard, the validation works fine but the JAlert doesn't show up. However, when I call the same function on a button click, the alert shows in IE. I am quite confused by this behavior and wo ...

Modify the font type within the data table

Just starting out with Java and I'm trying to figure out how to change the font family for all texts (header, footer, and body) in a datatable. Any tips on how to do this? I've looked through datatables.jqueryui.css but couldn't find anythi ...

After installing webpack and babel, the npm start command does not seem to be functioning as

Recently, I developed an app using react-redux. To enhance its capabilities, I decided to install babel and webpack by following a tutorial. Visit here for the installation guide Sharing my webpack.config.js file below: const path = require('path ...

Container div's vertical scroll is being hindered during initialization of TinyMCE/CKEditor

When utilizing TinyMCE in textareas loaded via AJAX callback within a colorbox modal window containing jQuery UI tabs panels, an issue arises. The panel holding the textareas is scrollable (overflow-y:auto), but upon initializing TinyMCE on these new texta ...

Experiencing the error message "Unable to access property 'innerHTML' of null" despite initializing the corresponding ID

After doing some research, I discovered that this issue usually arises when the specific div is not loaded yet or simply does not exist. My code is set to loop continuously, ensuring that even if it wasn't fully loaded the first time, it will be by th ...

Changing divs using JavaScript in an ASP.NET MVC application

I am making an AJAX request to retrieve Question1-Question10 from the back-end Below is the code for the request: <script> $(document).ready(function() { question_block(); }); function question_block() { $.ajax({ url: '@Url.Act ...

Error: When attempting to send a message in a different channel, an undefined property 'send' is encountered causing a TypeError

I'm utterly stumped as to why I keep encountering this issue, so perhaps someone here can shed some light on it. The error message reads: TypeError: Cannot read property 'send' of undefined Here is the snippet of code in question: client.o ...

Why was the element with id=box-2 displayed outside of its designated box? Exploring the overlapping rule of floats in CSS

The stylesheet code is #box { width:400px; height:200px; border:1px solid black; } #box-1 { width:100px; height:100px; background-color:red; float:left; } #box-2 { width:100px; height:100px; background-colo ...

When the application is reloaded, will the localStorage data be reset or remain intact?

Looking for a way to store data consistently throughout my application, I've opted to use localStorage. However, I'm facing an issue where all the localStorage values are erased upon reloading the browser. Can someone shed some light on why this ...

Uncovering the User's Browser Specifically for UC-Mini and Opera-Mini

I'm in need of a script that can identify if the user's browser is uc-mini or opera-mini. These particular browsers do not support the "transition" feature. Therefore, when this specific browser is detected, I would like to deactivate the "trans ...