:active pseudo-class malfunctioning on button element

edit: I have discovered that the :active pseudo-class is not working properly in Chrome, but it does work in Edge. As a beginner in coding, I am trying to figure out why this issue exists.

I am currently attempting to replicate the google homepage and struggling with the button effects. Specifically, I am having trouble with the :active pseudo-class.

My intention was to create a light blue 1px border for the :active state, replacing the gray border from :hover. However, the result is an unexpectedly thick black border instead.

Even after including all the necessary sequences (:link, :visited, :hover, :active), the problem persists. Any advice on how to resolve this?

.btn {
padding: 10px;
border: solid 1px #fff;
border-radius: 3px;
background-color: #ebebeb;
font-size: 15px;
}

.btn:hover {
border: solid 1px #b3b3b3;
}

.btn:active {
border: solid 1px #cddbf1;
}

.btn1 {
padding: 10px 15px;
}

.btn2 {
margin-left: 10px;
}
<div id="search-buttons">
<button type="button" class="btn btn1">Google Search</button>
<button type="button" class="btn btn2">I'm Feeling Lucky</button>

Answer №1

The color change is quite subtle, transitioning from active to hover color quickly.

If you're looking for a persistent state after clicking, consider using the focus pseudo class that remains even when the user clicks away (until the next click).

.btn {
  padding: 10px;
  border: solid 1px #fff;
  border-radius: 3px;
  background-color: #ebebeb;
  font-size: 15px;
}

.btn:hover {
  border: solid 1px #b3b3b3;
}

.btn:active, .btn:focus {
  border: solid 1px #cddbf1;
}

.btn1 {
  padding: 10px 15px;
}

.btn2 {
  margin-left: 10px;
}
<div id="search-buttons">
  <button type="button" class="btn btn1">Google Search</button>
  <button type="button" class="btn btn2">I'm Feeling Lucky</button>
</div>

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

Using typefaces in mobile native apps

@font-face { font-family: "Frodo Simplified Italic"; src: url("../resources/FrodoSimplified_It.ttf"); } Utilizing a HTML5 application that is embedded within an iframe of a webview includes the CSS statement above. The fonts specified within the state ...

Dealing with checked input type='checkbox' in React - A guide

Having a set of checkboxes, some already checked and some to be updated by the user. The issue here is that while the checkboxes render correctly initially, they do not change upon clicking. The 'checked' value does get updated when onChange is t ...

The CSS does not get applied to the returned element in Next JS

When I create a function to return a DOM element with an associated className, the local style doesn't seem to be applied. For example: export default function thing(){ const elem = function(){ return (<div className="myCss">Hello< ...

Having issues with my html file's navbar-right functionality

As a beginner in angular, I am trying to create a simple navbar. In my project's .json file, Bootstrap is loaded like this:- "styles": [ "./node_modules/bootstrap/dist/css/bootstrap.min.css", "src/styles.css ...

Combining a Hyperlink with a Table Target

I'm currently trying to find a way to target both a table cell (TR > TD) and a hyperlink within the same row. Here's an example of the HTML: <div class="CourseLayout"> <table width="100%" border="0" cellpadding="0" cellspacing="0"&g ...

What is the best way to display my menu bar when the icon is hovered over?

I want to create a menu bar similar to the one found on . I am unsure of how they achieved this effect, but it seems to involve a scroll-over action. However, when I attempt to replicate it, the words still appear even when the menu bar is collapsed. < ...

Issue with closing Bootstrap modal from an external file

I've implemented a modal feature using bootstrap. The modal is opening fine, but I'm facing an issue where it doesn't close when clicking on the cross or close button. This snippet is from my index.php file: <div id="editar" class="moda ...

Utilizing jQuery time intervals within a jQuery click event: A step-by-step guide

For my dropdown menu project, I am facing an issue where the menu bar is not reappearing after collapsing the dropdown. It seems that the jQuery function responsible for toggling classes within a time interval is not executing properly. Specifically, the " ...

Firebase hosting adjusts the transparency of an element to 1% whenever it detects the presence of CSS opacity

I'm currently working on a website using Vue.js and Firebase. Everything runs smoothly locally, including a button with a desired low opacity. However, when I deploy the site to Firebase Hosting, the button's opacity inexplicably changes to 1% an ...

HTML link with "mailto:" not opening in a new tab

Just posted for the first time! I'm attempting to create a mailto link using 'templated' JavaScript that pulls specific data from a JSON object: var menu = { "menu": [ { "title": "let's talk", "link": "mailto:<a href ...

I am in need of setting up two rows side by side using the display

I'm trying to have two rows side by side using display grid, but I'm facing some issues. When I use the following CSS... .grid-container { display: grid; grid-template-rows: auto auto; grid-template-columns: auto; grid-column-gap: 100px;} It cre ...

Tips on keeping an HTML element from shifting when resizing the browser window (how to lock an element in a specific position on a webpage)

As a newcomer to front-end web development, I recently attempted creating a basic responsive page. While working on this project, I encountered an issue with the candle holder image. This image is size-responsive, meaning it adjusts in size as the browser ...

"Exploring the Power of Jsoup for Selecting

I'm attempting to extract all the links nested within the div class news column index. Here is a snippet of the HTML structure: https://i.stack.imgur.com/zdFWS.jpg Below is the code I have used, but unfortunately, it's not yielding any results. ...

Modify the text or background shade of the Bootstrap date picker

I have successfully integrated the bootstrap date picker (view figure below) and it is functioning as expected. The code appears like this: <div class="input-group date"> <input name="departure" type="text" class="form-control" id="departure" ...

Triggering a JQuery Toggle Button

This is the code I'm currently working with: $('.access a').toggle(function() { $('link').attr('href', 'styles/accessstyles.css'); $('body').css('font-size', '16px'); }, fu ...

What is the most effective way to show an error message within the login form itself?

I'm currently dealing with a dilemma involving my login.php and login_process.php files. The login form is in the former, while the validation process occurs in the latter. I'm struggling to figure out how to display error messages on the login f ...

In CSS, the primary consideration is consistently maintaining a uniform height for the main section

In the process of developing our website, we have a main section (div main and mainholder) with a maximum height set at 770px. Whenever the content in this section exceeds that height, it gets cut off on the page. However, we want the height of this sect ...

Compiling SCSS to CSS in Vue.js is a breeze

I am working on a vue js project that includes scss files. My goal is to compile these scss files into css and store them in the public folder. How can I achieve this? Should I make changes to the vue.config.js file? const path = require('path'); ...

Guide to creating scroll-based animations for a Div element

I've been brainstorming ways to rotate a div as I scroll. My goal is to recreate the effect shown in this codepen. However, I'm struggling to implement scrolling functionality. What I envision is scrolling down causing the word Data to rotate in ...

Ways to create a back-and-forth transition across a sequence

Is it possible to create an animation that changes the width of an element once, then reverts back after a pause? I want this transition to occur over a three-second interval followed by a two-second delay. How can I achieve this? Below is the code I have ...