Achieving one-directional movement in Line by utilizing scale manipulation in CSS

hr:hover {
transform:scaleX(50.0);
}

CSS when Hover

hr 
{  
position: absolute;
transition: transform 1.5s ease-out;
width: 3%;  
height: 3px;  
background-color: white;      
margin-left: 20%;  
margin-top: 10%; 
}  

CSS of Line

Is there a way to scale the HR element to only go horizontally left on hover instead of both ways?

Also, how can I add a class name to my HR elements so that I can have multiple of them with different styles?

I managed to fix the issue by assigning a class name ".line" to my HR element.

.line
{
content: normal;  
position: absolute;
transition: transform 1.5s ease-out;
width: 10%;  
height: 5px;  
background-color: white;      
margin-left: 20%;  
margin-top: 10%; 
}  

Despite trying, I still cannot figure out how to make the scaling effect move only to the left side.

Answer №1

To adjust the scale direction, use the transform-origin property.

The transform origin determines the point from where transformation values are calculated. For example, setting it to the far right will make the scale move towards the left.

Additionally, you can assign a class to the hr element:

<hr class="divider" />
.divider:hover {
  transform:scaleX(50.0);
}
.divider {
  position: absolute;
  transition: transform 1.5s ease-out;
  width: 3%;
  height: 3px;
  background-color: white;
  margin-left: 20%;
  margin-top: 10%;

  /*
    Customize the scale direction
    by specifying the origin:
  */
  transform-origin: center right;
}

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

What is the best way to restrict the amount of photos displayed on each page?

I am having an issue with displaying a set number of images on each page. Despite setting a maximum limit for the number of images shown, all the images are still appearing on any given page. Here is the PHP logic I have written: $counter = 0; foreach ...

Updating a component property value through the template

Consider the code snippet below: import { Component, OnInit,Input } from '@angular/core'; @Component({ selector: 'topic-details', templateUrl: './detailpane.component.html', styleUrls: ['./detailpane.component.scs ...

Is there a way to eliminate the gap under the image?

https://i.sstatic.net/d73jo.jpg Is there a way to eliminate the gap under the image? ...

What is the proper way to include a forward slash at the end of my web addresses?

I need assistance adding a slash at the end of all my URLs. Currently, I am using a .htaccess file to remove the .php extension as shown below: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] Now, I would l ...

Guide on linking an HTML table to an Excel spreadsheet through PHP

In a project I'm working on, there is a table with columns for name, attendance status, date, and times in and out. I am looking for ways to connect this system to an Excel spreadsheet acting as the database using PHP. I have attempted to learn from ...

The default setting for the calendar picker indicator should be enabled

Whenever I hover my mouse over it, an indicator pops up, but I want to make it the default <input type="date" class="form-control" name="Date" [(ngModel)]="opening_date" (ngModelChange)="Operating()" style="width:550px" required> inp ...

Combining the results of two JavaScript range sliders to calculate commissions

I am currently working on developing a commission calculator with sliders. My goal is to have two sliders that can show the sum of their values combined. Although I have managed to get both slider outputs, I am struggling with converting them into a total ...

Page Content Fails to Load Without Reloading

I am currently working on a simple project using React with TypeScript, and I have run into an issue where the page content does not refresh as expected without having to reload the page. I am unsure of the underlying cause of this behavior. I have include ...

how to retrieve the class name of a checkbox solely when it has been checked

I have some HTML code with two checkboxes, each with different class names: <p class="text"> <input type="checkbox" value="Yes" id="ques11" name="radiobutton" class="option_1" /> <label for="ques11">True&l ...

Locate the closest pals near my present whereabouts

Is it possible to find my friends by obtaining their location from their mobile phones when they are near me? I have a code snippet below with the variable cities where I can input the numbers of my friends. Can I achieve this or do I need to make some m ...

Expanding Column Width Dynamically with Bootstrap When Text is Added

My HTML Code presents a challenge that I need help with: <!DOCTYPE html> <html lang="en"> <head> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.mi ...

Input additional content within the HTML texarea box

Can lines be added to an HTML textarea for a notebook paper-like effect? I'm thinking something similar to this: ...

What causes the entire page to disappear when the screen is adjusted to mobile width?

I'm facing an issue with my ReactJS screen. Everything works perfectly until I resize the screen to mobile width (sm of Material UI) and then everything turns into a WhiteScreen. I've been trying to debug this but can't seem to find the root ...

What is the best method to calculate the dimensions of flex items without relying on percentages?

Imagine this as the structure of my HTML, with an unspecified number of div elements: <body> <div></div> <div></div> <div></div> <div></div> <div></div> <div>& ...

Populating a Dropdown Menu with JSON Data using JavaScript

I am facing an issue with populating my dropdown menu using data from my JavaScript file. Whenever I click the button, three objects are added to the dropdown, but I only want them to show individually upon clicking. Additionally, I am getting [object obje ...

How can I create an HTML select dropdown menu with a maximum height of 100% and a dynamic size?

The dropdown menu I created using an HTML select tag contains a total of 152 options. However, the large number of options causes some of them to be out of view on most monitors when the size is set to 152. I attempted to limit the number of displayed opti ...

Prevent caching in AngularJS stateprovider and Gulp

Looking for ways to prevent caching of my Html files without success. Attempted using rev & rev-replace, however only the file names are being changed and not the references in the stateprovider, leading to a "files not found" error. This snippet from my ...

The event binding for input with the specific class `.SomeClass` in the document is functional in Chrome, but encounters issues in Internet Explorer

I am facing an issue where I have a span with the contenteditable attribute and a function to detect input within it. //TextArea <span class="SomeClass" contenteditable></span> //Function $(document).on("input", ".SomeClass", function () { ...

What is the best way to manage these interconnected Flexboxes when using align-items: stretch?

Trying to put this into words is quite challenging, so I created a simple diagram for better understanding: https://i.stack.imgur.com/TMXDr.png The outer parent uses flex with align-items:stretch to ensure that both col 1 and col 2 have the same height. ...

What is the best way to position a small image within a menu?

Is there a way to adjust the position of the arrow image within the <li> element without affecting the layout of the unordered list? Below is the code snippet for reference: body { margin: 0; padding: 0; } nav { width: 100%; background: # ...