Can someone please help me understand why my CSS transform scale isn't functioning properly?

I've developed a JavaScript function that enlarges a button and then smoothly shrinks it back to its original size.

The function successfully changes the color of the button to blue, but for some reason, it's not working with the transform property. Any insights on why this might be happening?

Appreciate any help! :)

var btnE = document.querySelector(".btn-e");

btnE.addEventListener('mouseover', function() {
  btnE.classList.add("btn-eScript")
})
btnE.addEventListener("transitionend", function() {
  btnE.classList.remove("btn-eScript")
})
.btn-e {
  margin-left: 155px;
  background-color: rgba(83, 155, 232, 0.9);
}

.btn-s {
  margin-left: 120px;
  background-color: rgb(236, 130, 139);
}

.btn-s,
.btn-e {
  text-decoration: none;
  color: white;
  font-size: 90%;
  font-weight: 100;
  text-align: center;
  padding: 10px 20px;
  border-radius: 25px;
  transition: 0.15s;
}

.btn-eScript {
  color: blue;
  transform: scale(1.5);
}
<div class="btns">
  <a class="btn-s" href="#">More Examples</a>
  <a class="btn-e" href="#">More Examples</a>
</div>

Answer №1

To make your button visible, you must include a display property:

.btn-s,
.btn-e { display: inline-block; } 

Check out this JSFiddle for more details.

var btnE = document.querySelector(".btn-e");
btnE.addEventListener('mouseover', function() {
    btnE.classList.add("btn-eScript")
})
btnE.addEventListener("transitionend", function() {
    btnE.classList.remove("btn-eScript")
})
.btn-e {
    margin-left: 155px;
    background-color: rgba(83,155,232,0.9);   
}

.btn-s {
    margin-left: 120px;
    background-color: rgb(236, 130, 139);

}

.btn-s,
.btn-e {
    text-decoration: none;
    color: white;
    font-size: 90%;
    font-weight: 100;
    text-align: center;
    padding: 10px 20px;
    border-radius: 25px;
    transition:  0.15s;
    display: inline-block;
}

.btn-eScript {
      color: blue;
      transform: scale(1.5);
}
<div class="btns">
                <a class="btn-s" href="#">More Demos</a>
                <a class="btn-e" href="#">More Demos</a>
            </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

Tips for selecting an <select> option value based on an URL parameter automatically

I have a 2-step form where I am successfully passing the first name in the URL from step 1 to step 2, but I am struggling to do the same for a select field. Here's an example of what I have: In the URL: ?firstname=Bob Form Field: <input type= ...

Guidelines on navigating a blank page using the Nuxt-js method

I have run into an issue in my Nuxt.js project where I need to open a link in a new target when a user clicks a button. Despite trying various solutions, I haven't been able to find a workaround within the Nuxt.js framework itself. <a :href=&qu ...

Ensure that each of the two divs maintains a 16:9 aspect ratio, and utilize one div to fill any remaining empty space through the

This layout is what I am aiming for: https://i.sstatic.net/uZdty.png While I can achieve a fixed aspect ratio with a 16:9 image by setting the img width to 100%, I run into an issue where the height scaling of flexbox becomes non-responsive. The height re ...

A step-by-step guide on smoothly transitioning between elements using Vue-Carousel on a click event

Today marks my first question here and I'm excited! Can anyone guide me on how to implement sliding on click element with Vue-Carousel? I want to slide to the right with just a single click on my input button. Here's the code snippet I have base ...

Issues with React-markdown, including malfunctioning gfm tables and various other difficulties

My journey to render markdown in react using the react-markdown library has hit a few bumps along the way. I've encountered 2 issues and have been pondering 1 question that remains unanswered: Upon implementing the remark-gfm plug-in, the tables fail ...

I am unable to log in using bcryptjs, but I have successfully been able to register a

Hey there! So I'm diving into Nodejs and I've managed to create a simple login/register API. For password encryption, I'm using bcryptjs. Testing it out on postman, I can successfully register a new user. However, when attempting to login wi ...

Tips for storing the state using Localstorage?

Greetings to the person reading this message! I am relatively new to programming and I have a query... I created a Navigation bar: body > div > nav > div > ul > li*10 I have implemented the styling in CSS. //Navigation Bar const list = ...

Controlling the activation of a button on a parent modal popup from a child within an IFrame using javascript

I am struggling to toggle the button on the main window from the child window. Here is a snippet from the main page: <ajaxToolkit:ModalPopupExtender ID="mpeTest" runat="server" CancelControlID="btnClose" PopupControlID="pnl1" TargetControlID="showMp ...

When I hover over it, my play button refuses to show up

I am in the process of creating a music streaming website and I would like the play button to appear when hovering over a song. However, I am encountering an issue with the CSS section overriding the others that are meant for different parts (I am using Fo ...

Tips for navigating back and forth on a support page by utilizing reaction await in discord.js

Here is an example of my code snippet: const Discord = require('discord.js') module.exports = { name: 'help', description: 'help', execute(message, args) { const embed = new Discord.MessageEmbed() ...

Reactive form allows you to easily format dates

Currently, the date displayed is 1/4/2022. We need it to display in the format 01/04/2022. Can we achieve this formatting using reactive forms with the sample Model form provided below? Thank you. How can we format it when starting from transactionStartD ...

Encountering the 'unsupported_grant_type' error while attempting to retrieve an access token from the Discord API

Having trouble implementing Discord login on my website. When trying to exchange the code for an access token from https://discord.com/api/oauth2/token, I keep getting the error { error: 'unsupported_grant_type' }. This is my code: const ...

"Flashes of canvas in constant motion between animated scenes

I have a practical exercise to do for school, but I am very new to HTML/JS. The issue I am facing is that my canvas is flashing, like it erases one image and then quickly displays another. I want both images to be displayed at the same time. Here is the co ...

Pressing a button will display a div element, which will automatically be hidden after 5 seconds

I'm working on an email submission form that displays a confirmation message below the input field when a user submits their email address. The confirmation text should fade out after 5 seconds. Here's the code snippet: <div class="input-gro ...

obtain access token using JavaScript

I am trying to obtain an access token using my refresh token in JavaScript. Here is the code snippet I am using: $.ajax({ type: "POST", contentType: "application/x-www-form-urlencoded", url: "https://accounts.google ...

The parameters of a submitted form in JQuery are constantly changing

I attempted to pass a value to another page through the URL. I cannot hardcode it directly in the HTML because I need to gather information from multiple steps first. Therefore, I must modify the form action before it is submitted. Below is the form struc ...

Execute MySQL query when the content of an HTML text field changes

My goal is to check if the value entered in an input text box matches any rows in a database. I want the DB to be searched when text is typed into the input field. <input type='text' name='barcode'> I would like it to search the ...

Change the text color of the Vuetify button to customize its appearance

Is there a way to change the default active color for button text in a toolbar using CSS? v-btn(:to="item.path" active-class="v-btn--active toolbar-btn-active") {{item.meta.title}} I attempted to override it with this custom class: .toolbar-btn-active { ...

Basic stacked or segmented bar in HTML

Instead of starting from scratch, I'm in search of insights on how to develop a stacked/segmented bar or find an existing control for this purpose. Here are my requirements: Horizontal bar Standard html Color-coded segments using CSS Segments propor ...

Angular is failing to retrieve data from FS.readFile using promises

My goal is to utilize an Angular service to decide whether to call fs.readFile or fs.writeFile based on the button pressed, in order to explore the interaction between node and angular promises. Although I have managed to read and write files, I am facing ...