Button styles that have been verified will not be shown in Firefox

Hello, first time poster here!

Client specifications for CSS:

button {
  border: 1px solid #B8B7B8;
  border-radius: 8px;
  height: 4em;
  margin: 25px 2px 25px 0;
  text-align: center;
  text-decoration: none;
  width: 4em;
}

button:active,
button:checked,
button:focus,
button:hover {
  box-shadow: 0 0 0 1.5pt #068985;
  -moz-box-shadow: 0 0 0 1.5pt #068985;
  outline: none;
}
<button type="button">Button</button>

The buttons are standard HTML <buttons></button>s.
They function properly on other browsers, but I am facing an issue with Firefox.

Is there a way to maintain the border of a clicked button?
The :hover state works fine but not much else. I have scoured the internet for a solution without luck.

Thank you in advance!

Side challenge - If anyone can help me create spacing between the button and its custom outline when selected, I will dedicate a blog post to you!

Answer №1

To implement a checked feature on click, you can simply add a class to the button (or div for spacing). Additionally, to create space between the button and a custom outline, you can add a parent div and apply border styles to it.

For a working example, please refer to this jsfiddle: https://jsfiddle.net/ajm5wnos/32/

var checked=false;

document.getElementById("myButton").addEventListener("click", (elem)=>{
  event.target.parentNode.classList.remove("checked");
    checked= !checked;
if(checked){
  event.target.parentNode.classList.add("checked");
  }
})
button {
  border: 1px solid #B8B7B8;
  border-radius: 8px;
  height: 4em;
  text-align: center;
  text-decoration: none;
  width: 4em;
}

#buttonParent{
  padding:2px;
  display:inline-block;
  border-radius: 8px;
}

.checked{
  padding:2px;
  display:inline-block;
  border-radius: 8px;
  box-shadow: 0 0 0 1.5pt #068985;
  -moz-box-shadow: 0 0 0 1.5pt #068985;
  outline: none;
}
#buttonParent:active,
#buttonParent:focus,
#buttonParent:hover {
  box-shadow: 0 0 0 1.5pt #068985;
  -moz-box-shadow: 0 0 0 1.5pt #068985;
  outline: none;
}
<div id="buttonParent">
  <button type="button" id="myButton">Button</button>
</div>

Thank you.

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

Issues with hover functionality in React Material Design Icons have been identified

I'm facing an issue with the mdi-react icons where the hovering behavior is inconsistent. It seems to work sometimes and other times it doesn't. import MagnifyPlusOutline from "mdi-react/MagnifyPlusOutlineIcon"; import MagnifyMinusOutli ...

Having trouble with Viewport CSS being restricted by Blogger?

I've been working on configuring my personal blog, which is hosted on Blogger, to properly adapt to the Windows 8 IE snap feature. Through my research online, it has been suggested that I include a @viewport in the CSS. However, it seems like the CSS ...

Which Javascript/Css/HTML frameworks and libraries would you suggest using together for optimal development?

Interested in revamping my web development process with cutting-edge libraries, but struggling to navigate the vast array of tools available. The challenge lies in finding a harmonious blend of various technologies that complement each other seamlessly. I& ...

Is there a way to ensure the collapsible item stays in its position?

I'm encountering an issue with the display of items within collapsible cards. Here is what it currently looks like: And this is how I want it to appear: Is there a way to achieve the desired layout using Bootstrap's Grid or Flex Layout? Here i ...

Arrange the icons in multiple rows to ensure an equal distribution of icons on each row

There are 12 image icons displayed in a row within div elements using display: inline-block. However, when the browser window is resized, I would like the icons to be arranged on two or more rows so that each row contains an equal number of icons. ...

Resize Pictures in Carousel for Smartphones

Currently, I am in the process of optimizing my website for mobile devices. The NivoSlider, which is used throughout the site, does not seem to scale well on smaller screens. Despite trying various methods in the mobile section of my stylesheet such as " ...

Issue with connecting Drupal 8 theme styling to website pages

Although the theme is functioning properly, the CSS styles are not being applied. Even when inspecting the developer console in Firefox, there seems to be a disconnect with the page. I verified that manually applying the CSS through the developer console i ...

What is the process for implementing a third-party component in my web application?

After some experimentation, I've discovered that it's necessary to include the link to the css files in the header and then mention the link to the js files before the closing tag. However, I encountered difficulties when trying to use a compone ...

Is there a way to show textboxes stacked on top of each other without causing them to

Here is the HTML snippet I am working with: <div> <p><label>Faculty <input type="text" class = "f"></label></p> <p><label >Department<input type="text" class = "f"></label></p> ...

What is the best way to prevent a sticky element from scrolling along with the

I am looking to prevent a sticky div from taking up space on the website. It currently sticks to the desired position as expected. HTML <div v-if="isToastActive" class="toast"> <span class="message">{{ messa ...

Implementing a Radial Cursor with a Custom Background Image in JavaScript

I am attempting to implement a radial cursor on a website that features a background image. Currently, I am facing two main issues: The radial cursor works in Chrome but not in Firefox. When using Firefox, I encounter a parsing error related to the "bac ...

Customized function enabling dynamic menu display based on varying screen dimensions

Looking for assistance with JS and jQuery as I am relatively new to it. Any help would be greatly appreciated... I'm currently working on a responsive header where I want to implement onclick functions for mobile and tablet resolutions only. I' ...

Tips for showcasing HTML as code tailored to certain programming languages

While browsing the web, I stumbled upon a website that had SQL code displayed with specific classes and styles applied to it. For example, table names were colored blue when inspected. Here is a glimpse of what I encountered: I'm curious about how t ...

Google Map with rounded corners that have a transparent design

Trying to create a circular Google map using CSS3 border-radius, but having issues with browsers other than Firefox. Here's the code snippet: <div class="map mapCircle" style="position: relative; background-color: transparent; overflow: hidden;"&g ...

Using JQuery to switch out images that do not have an ID or class assigned

Currently, I am using a Google Chrome Extension to apply an external theme to a website. Unfortunately, the logo on the site does not have an ID or class that can be used to call it. I am searching for a solution to replace it with a different image. My ...

Utilize various CSS styles for individual sections within a multi-page website

Having a web page with multiple subpages each having their own specific CSS can be quite challenging. Sometimes, when all the CSS files are applied globally, they tend to mix with each other causing a headache for developers. One common approach is to decl ...

Ensure your mobile site is optimized for full width display

Imagine a webpage with a fixed width of 1280px. Is there a way to instruct a smartphone to automatically scale this page to full width upon loading? Currently, I am using: <meta name="viewport" content="width=1280, initial-scale=1"> However, it d ...

Is there a more effective method for positioning items in a navigation bar other than using padding-left?

Hey there, I've been working on this navigation bar for quite some time now and finally found a way to center the menu items. However, I want to make sure I'm doing it the right way. Does anyone have suggestions on how to center all the "li" elem ...

Issues with CSS not being applied when the page content exceeds the viewport

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>Unique Title</title> <style> #div1 { posit ...

Personalize the color and icon of the checkbox marks in sapui5

I'm trying to customize the color of the tick on a UI5 checkbox. After inspecting the CSS, I noticed that it can be modified using the ::before selector: To target the checkbox, I added a class called .accept and defined it in the CSS file like this: ...