Does anyone know why this code isn't functioning properly on Firefox?

This code performs as intended in Chrome, but unfortunately does not function properly in Firefox.

ul {
    list-style:none; 
}

li {
    display:inline-block;
    border:1px solid black;
}

a {
    display:block;
    margin:10px;
}

a:hover {
    position:relative;
    top:-2px;
    color:red; 
}

and

<ul>
    <li><a href="#">Hi there</a></li>
    <li><a href="#">Hi there</a></li>
    <li><a href="#">Hi there</a></li>
    <li><a href="#">Hi there</a></li>
    <li><a href="#">Hi there</a></li>
</ul>

The issue is that in Firefox, instead of moving the text 2 pixels up on hover, it moves the borders down by two pixels. How can this be corrected?

If no solution is available, then please recommend an alternative version that achieves a similar effect on the text within the .

Answer №1

Consider making the following adjustment:

a { display:block; ... }

alter to

a { display:inline-block; ... }

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

Receive the innerHTML of an Element after appending additional Elements - Selenium

When working with my table in HTML, I have noticed that the <td> tag can be accessed in two different ways: 1. <td><font size="4" face="Arial"><i>Google</i></font></td> 2. <td>Google</td> I am curr ...

Limiting the scrolling capability within a flex container by using the nowrap

When using flex with nowrap, it appears that the horizontal scroll bar only allows moving to the right while the items on the left remain hidden. To demonstrate this issue, I have created a sample on CodePen: http://codepen.io/anon/pen/QpgvoZ This behavio ...

Looking to expand the width of the sub menu to reach the full width of the

Is there a way to use CSS to make a sub-menu start from the left side of the screen instead of starting it below the parent item? nav { margin: 0 auto; text-align: center; } nav ul ul { display: none; } nav ul li:hover > ul { di ...

Web server decides on "Multiple Options" while utilizing %3F instead of "?" in the URL

I have been using the Lazarus-IDE for a project and encountered an issue with one of its components that doesn't accept "?" in the URL for online help info. I attempted to encode "?" as "%3F" in the URL, thinking it was the correct encoding, but both ...

Is it acceptable to utilize a UUID as an HTML tag ID without encountering any problems?

I need to handle dynamic content accessible through an index on a side panel. When a user selects an element from the side panel, I use the ID to determine which data they're requesting so that I can generate the corresponding content for the main sec ...

Using AngularJs: Invoking Service/Provider in app.config

I need to access my service from within app.config. While searching for a solution, I came across this question, which presented a potential solution that I attempted to implement (not the accepted answer, but the one below with the title "Set up your ser ...

Arrange the child divs on top of the parent div

<div id="1"> <div id="2"> </div> </div> It is proving challenging to position div2 above div1 in the vertical dimension. Applying a negative top position does not have the desired effect, as it appears that the top border of the ...

Connecting queries in php

I am looking to connect searches from a checkbox form together. For example, if I select checkboxes a and b, I want the search results to display two different outcomes. <form role="form" action="R.php" method="post"> <div class="form-group"&g ...

Change the width of a div element without causing text to wrap when resizing the browser window

Looking to create a layout with three div elements, each containing an h1 element. The goal is to have the first div on the left side, the second div in the center, and the third div on the right side, all in a single row. When the window is resized for re ...

Implementing Material UI datetime-local feature with no minute selection

Is there a way to hide minutes in a TextField with type = datetime-local? <TextField label="From" type="datetime-local" InputLabelProps={{ shrink: true, }} /> This is how it appears on my end: screenshot ...

Invoke Javascript through CSS selector

On my webpage, I have implemented a mousemove-mask feature that was inspired by an existing codepen. However, there is one significant issue that I can't seem to resolve on my own. Despite my attempts to fix it, I believe someone with more expertise c ...

Implementing CSS Pre-loading in an Angular Application with Webpack and Heroku

My current setup involves an Angular application (v4.0.1) with webpack deployed on Heroku. I have a loading spinner in place to show while the app is loading, and it works well locally. However, when deployed on Heroku, the loading spinner (specifically th ...

Ways to move the cursor to the search field after the placeholder text

I'm working on a Vue project with a small app featuring an input type search. The issue I'm facing is that the cursor appears at the beginning of the input, whereas I want it to appear after the placeholder text. How can I make this adjustment? ...

Code for activating datalist on Safari and Opera browsers

As I was wrapping up work on a website, I realized that Safari doesn't support the datalist feature in HTML. This was quite troublesome since a significant portion of the site's audience consists of individuals who may not be very tech-savvy, mak ...

The stack trace indicates an internal findElement function within the FirefoxDriver prototype

Using the selenium framework in conjunction with firefox to navigate a webpage. The site utilizes ajax for loading new content upon clicking the Show More Results button. Oddly enough, encountering an error every time trying to locate and interact with th ...

Incorporating docsify CSS styling into Markdown within the VScode environment

When it comes to building my blog, I've decided to go with docsify and manage my markdown files using VScode. I wanted a preview of my blog, and after noticing that <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/t ...

Do discrepancies exist between ' and " symbols?

Similar Question: When to Use Double or Single Quotes in JavaScript Difference between single quotes and double quotes in Javascript I scoured this site and did some internet sleuthing (in that order...) trying to find the answer to this burning q ...

Is there a way to dynamically adjust the overflow-y property based on the height?

Trying to make the overflow-y-visible property visible if the height is too small, otherwise using overflow-y-hidden with tailwind CSS and React. Struggling to achieve this as I can't use sm, md, etc. for height like I can for width. Could someone pl ...

A dynamic jQuery plugin that replicates the smooth page sliding animation found in iPhone apps

Currently, I am in search of a jQuery plugin that has the capability to navigate users to different pages on a website with a sleek sliding animation, similar to what we see in some widely used iPhone apps. Despite my best efforts to create this functional ...

"Selecting elements with CSS using the 'element'

While exploring some websites for studying purposes, I came across this code snippet. .site-header .widget-area span.but As a beginner in CSS, I'm curious to know more about the span.but part. Is it similar to the :not pseudo selector? ...