How come my transform command is not functioning on both axes as intended?

My transform: translate(10px 10px) isn't functioning as expected. When I only provide a value for the x-axis, it works fine. Using translateX and translateY separately works as well, but using both at the same time doesn't work. This means I can only translate the images on one axis but not on both simultaneously. Any suggestions?

.gallery {
  text-align: center;
}

.gallery img {
  position: relative;
  width: 30%;
  height: calculate(width*66%);
  margin: 10px;
  animation-name: blendin;
  animation-duration: 3s;
  transition: ease-in-out all 300ms;
}

.gallery img:hover {
  box-shadow: 10px 10px 10px black;
  transform: translate(10px 10px);
}
<div class="gallery">
  <img src="elbe.jpg" alt="Elbe">
  <img src="tisch.jpg" alt="Tisch">
  <img src="spiegelung.jpg" alt="Spiegelung">
</div>

Answer №1

The CSS property "translate" requires a comma to separate values in CSS. Instead of:

transform: translate(10px 10px);

it should be written as:

transform: translate(10px, 10px);

.gallery {
  text-align: center;
}

.gallery img {
  position: relative;
  width: 30%;
  height: calculate(width*66%);
  margin: 10px;
  animation-name: blendin;
  animation-duration: 3s;
  transition: ease-in-out all 300ms;
}

.gallery img:hover {
  box-shadow: 10px 10px 10px black;
  transform: translate(10px, 10px);
}
<div class="gallery">
  <img src="elbe.jpg" alt="Elbe">
  <img src="tisch.jpg" alt="Tisch">
  <img src="spiegelung.jpg" alt="Spiegelung">
</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

Guide to creating a see-through modal using bootstrap?

I am currently utilizing Bootstrap to design a modal within a Navbar. When the Login or Signup buttons are clicked, the modal is displayed. The Navbar has a transparent color by default, changing to white upon hovering over it. I wish for the modal to also ...

What is the best way to align my text to the bottom of a table header in a vertical manner?

I am working with a series of nested tables and this is the basic structure: <table> <tr> <td> <table> <thead> <tr> <th></th> <th ...

What is the reason for the addEventListener function not being able to access global variables?

I have set up an event listener function to utilize popcorn.js for displaying subtitles. Additionally, I have created functions that are unrelated to popcorn.js outside of the event listener and declared a global variable array. However, when attempting ...

Transforming Input Background Color with jQuery based on Matching PHP Array Entry

I am looking for a solution to implement form validation in PHP. The form has 3 fields: user, id, and email. When a user enters their name or id in the respective input fields, I want to check if the entered value matches any of the values in the PHP arra ...

Using JQuery and Bootstrap: Adding an image from a selection of images to a carousel

As a beginner in the world of JQuery, I am currently working on creating a customizable carousel where users can select pictures to add to the carousel with just one click. On the left side of the page, there is a selection of images to choose from, while ...

Tips for shortening extra text in a non-wrapping HTML table cell and adding "..." at the end

My HTML template includes text imported from a database field into a <td> tag. The length of the text can range from 3 to 200 characters, and the <td> spans 100% of the screen width. If the text surpasses the width of the screen, I want it to b ...

Trigger a Jquery sound when an HTML result is found and displayed

I am using a Jqgrid to display a table. Within the "return" column, along with other data, there is a span element like the following: <span class="return" id="ret0>4.25%</span> My webpage contains multiple instances of these spans: < ...

The sidebar stays fixed in place and doesn't adapt to varying screen resolutions

Check out my website at . I have a fixed, blue sidebar on the left side of the page to ensure its content is always visible. However, I'm facing an issue with smaller resolutions like 1024x768 where some bottom content is cut off. How can I adjust the ...

tag assistance for incorporating an attribute without a value

Trying to create: <div data-dropdown-content class="f-dropdown content"> using the tag helper. It seems there is no specific syntax for attributes without values <%= tag(:div, :class => "f-dropdown content", data: {dropdown-content: ""}, :& ...

Full-width sub menu within the menu

I'm trying to make a sub menu appear below my main menu that is the same width as the main menu, which has a fixed width. I want the sub menu to adjust its width based on the number of links it contains. Is this even possible? Here's the code I h ...

Div sliding down from the top of the page

I have successfully created a pop up that appears when the user reaches the bottom of the page. Now, I am looking to implement a similar concept but have the pop up appear from the TOP of the page, at a specific location on the page instead of just top or ...

Ways to ensure that the ul navigation bar spans the entire bottom of the page evenly (without resorting to using table

This question has been previously raised on Stack Overflow with an insightful answer provided. However, I am encountering a specific problem in implementing it. My objective is to have a navigation bar (nav consisting of ul and its li items) occupy the en ...

Jquery refuses to conceal a particular element

I've encountered this issue before, but I'm facing a problem this time. I'm attempting to create a popup that is initially hidden. When clicked, the popup does appear, but I'm unable to close it. Additionally, when trying to change the ...

Mastering the placement of script tags in your Next.js application with Next Script

I'm in the process of integrating a third-party script into my Next.js website. This particular script adds an iframe right below its corresponding script tag. Therefore, it is crucial for me to have precise control over the placement of the script ta ...

Using jQuery and CSS to create a temporary placeholder for images that have varying sizes

I am currently developing an innovative image gallery feature where a temporary heart image is displayed for 1 second in place of the actual images (image 1, image 2 etc). If you want to view the implementation, check out my jsfiddle below: https://jsfid ...

Thumbnails failing to line up in a continuous row

Having an issue creating a row with 3 thumbnails as they are not aligning in a single row, instead each thumbnail is going into a different row. echo "<table>"; echo "<tr>"; echo "</tr>"; while($r ...

CSS and HTML modal not closing

I've been working on creating a custom popup using HTML, CSS, and some jQuery functions. My idea was that when I click on the main div, it should expand in size and display a cancel button, which it does successfully. However, the issue arises when tr ...

Ways to make certain HTML elements stay fixed on a webpage while allowing others to be scrollable

In this layout, the page features a navbar at the top followed by a row with two columns. The left column displays the user's profile information (such as profile picture and short bio), while the right column shows other information. However, when a ...

Conceal the toolbar element if it is not at the top of the page

I am encountering an issue with my toolbar. When I scroll down, the transparent background of the toolbar disappears and it looks like this: https://i.sstatic.net/YxZQe.png. How can I hide this component when the page is scrolled down and show it again whe ...

Can solid grid lines be shown using CSS instead of the default dashed grid lines?

Is there a method to achieve consistent and solid grid lines in C3 using CSS without specifying exact line values? For instance, consider C3's basic Grid Line example: var chart = c3.generate({ data: { columns: [ ['sampl ...