Ways to remedy the white line produced by CSS transform when hovered over?

Has anyone discovered a fix for the white line or border that appears when an element is transformed with CSS scale on hover?

I've tried various solutions such as: transform: translateZ(0),

-webkit-backface-visibility: hidden
, transform-style: preserve-3d, but nothing seems to work.

This issue is particularly noticeable on non-retina displays.

You can view a video here for those who may not see the problem, where you'll notice a 1px line at the bottom of the image.

section {
  padding: 100px 0;
}

figure {
  margin: 0;
  overflow: hidden;
}

figure:before {
  position: absolute;
  z-index: 2;
  content: '';
  width: 100%;
  height: 100%;
  background: rgba(43, 43, 54, 0.3);
  transition: background 0.7s cubic-bezier(0.2, 1, 0.2, 1);
}

.ct-image-container {
  display: flex;
  position: relative;
  transform: scale3d(1, 1, 1);
  transition: transform 0.7s cubic-bezier(0.2, 1, 0.2, 1);
}

.ct-image-container img {
  position: absolute;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  object-position: center center;
}

article:hover figure:before {
  background: rgba(43, 43, 54, 0.7);
}

article:hover .ct-image-container {
  transform: scale3d(1.1, 1.1, 1);
}
<html>

<head>
  <meta charset="UTF-8">
  <title>Document</title>

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <section>
    <div class="container">
      <div class="row no-gutters">
        <article class="col-md-6 col-lg-4 col-xl-4">
          <div class="ct-card-inner">
            <figure>
              <a href="" class="ct-image-container">
                <img src="https://images.unsplash.com/photo-1478033394151-c931d5a4bdd6?w=1568&ixid=dW5zcGxhc2guY29tOzs7Ozs%3D" alt="">
                <div class="ct-ratio" style="padding-bottom: 133.3%"></div>
              </a>
            </figure>
          </div>
        </article>
        <article class="col-md-6 col-lg-4 col-xl-4">
          <div class="ct-card-inner">
            <figure>
              <a href="" class="ct-image-container">
                <img src="https://images.unsplash.com/photo-1465126188505-4f04a0f23a4d?w=1550&ixid=dW5zcGxhc2guY29tOzs7Ozs%3D" alt="">
                <div class="ct-ratio" style="padding-bottom: 133.3%"></div>
              </a>
            </figure>
          </div>
        </article>
        <article class="col-md-6 col-lg-4 col-xl-4">
          <div class="ct-card-inner">
            <figure>
              <a href="" class="ct-image-container">
                <img src="https://images.unsplash.com/photo-1495250357898-6822052ef5b8?w=1650&ixid=dW5zcGxhc2guY29tOzs7Ozs%3D" alt="">
                <div class="ct-ratio" style="padding-bottom: 133.3%"></div>
              </a>
            </figure>
          </div>
        </article>
        <article class="col-md-6 col-lg-4 col-xl-4">
          <div class="ct-card-inner">
            <figure>
              <a href="" class="ct-image-container">
                <img src="https://images.unsplash.com/photo-1446080501695-8e929f879f2b?w=1567&ixid=dW5zcGxhc2guY29tOzs7Ozs%3D" alt="">
                <div class="ct-ratio" style="padding-bottom: 133.3%"></div>
              </a>
            </figure>
          </div>
        </article>

        <article class="col-md-6 col-lg-4 col-xl-4">
          <div class="ct-card-inner">
            <figure>
              <a href="" class="ct-image-container">
                <img src="https://images.unsplash.com/photo-1506512534708-3737d46bffe1?w=1650&ixid=dW5zcGxhc2guY29tOzs7Ozs%3D" alt="">
                <div class="ct-ratio" style="padding-bottom: 133.3%"></div>
              </a>
            </figure>
          </div>
        </article>
        <article class="col-md-6 col-lg-4 col-xl-4">
          <div class="ct-card-inner">
            <figure>
              <a href="" class="ct-image-container">
                <img src="https://images.unsplash.com/photo-1503924087716-07cbd5f49b21?w=1000&ixid=dW5zcGxhc2guY29tOzs7Ozs%3D" alt="">
                <div class="ct-ratio" style="padding-bottom: 133.3%"></div>
              </a>
            </figure>
          </div>
        </article>
      </div>
    </div>
  </section>
</body>

</html>

For my code example, check out this JSFiddle link.

If anyone has any insights on how to resolve this issue, your help would be greatly appreciated.

Answer №1

By including the CSS property backface-visibility: hidden; in your img tag, you should be able to resolve this issue.

Instead of my previous method, I am opting for this new approach:

Make sure to disable the following CSS code

img {
    position: absolute;
    width: 100%;
    height: 100%;

    /* max-width: 100%; */
    /* max-height: 100%; */
    /* object-fit: cover; */
    /* object-position: center center; */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

This should solve the problem!

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 on adjusting image dimensions in JTextPane using HTML and CSS in the Java Swing environment

I am looking to add an image (such as a formula created from LaTeX) into JTextPane, using HTML+CSS for text formatting and manually setting its size. I attempted the following approach: import java.awt.Dimension; import javax.swing.JFrame; import javax.swi ...

Move content off the screen using CSS3 translation

Throughout various projects, I have encountered the need to make elements on a webpage translate out of view (essentially making them fly out of the document). The idea was that by simply adding a class to the element, the CSS would take care of the animat ...

Troubleshooting a Border Problem in Bootstrap 5 Accordions

Having trouble with a Bootstrap 5 accordion header that has an icon drop-up menu. The bottom border disappears under the icon and I can't figure out why? HTML <div class="w-50 mt-5 mx-auto"> <div class="accordion favorites-f ...

What considerations should I keep in mind when changing the DOCTYPE from html 4.01 transitional to 'html'?

Firefox is telling me that my pages are being rendered in 'standards compliance mode' based on the doctype... <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> After changing it to < ...

Tips for placing a searchbox on top of a carousel?

I need to create a search box that overlays on top of a carousel image. I currently have the search box positioned absolutely, but it's not responsive as it doesn't stay within the carousel as the width decreases. How can I make it responsive whi ...

Excessive letter spacing in font-face causing display issues on Apple devices such as iPhone and iPad

Recently, I designed a website using some unique fonts that aren't supported on all devices. To ensure compatibility across various platforms, I converted the fonts to all major file formats, including SVG for iPhones and iPads. Surprisingly, this sol ...

How can I ensure a div expands over another element when hovering the mouse?

I have a development div in the footer with a hover effect that expands it. However, it is currently growing underneath the top element on the site. I want it to expand on top or push the element above. Website: I've tried using position, float, and ...

Can the styling and variables of Bootstrap4 be altered dynamically?

I have recently started working on a project that utilizes Bootstrap4 for design and layout. However, there is now a need for the ability to change certain core styles (such as font-face, primary color, and background color) dynamically at runtime. Curren ...

The CSS elements are positioned beneath the top border when applying a scale transformation within columns

I have a layout with 4 columns of images that I want to scale on mouse hover using the 'column-count' property. The first column works correctly, but the next three end up positioned under the upper border during the transformation. I've e ...

Using CSS to target specific attributes on standalone elements

Ever since I stumbled upon AMCSS, I have been utilizing standalone attribute selectors. Recently, I made the switch from Compass to cssnext, only to discover that syntax highlighting appears to be malfunctioning in Atom and other platforms where I tested i ...

What is the best way to modify the size of the letter background?

I'm facing an issue with a word that has a background color. While using the CSS property background-color: blue, allows me to give the word a background color and display: inline-block helps in sizing it exactly to the word, the problem arises when I ...

Problems with the design in the Opera browser

My website logo is displaying incorrectly in Opera, despite working fine in Firefox and Chromium. I've been trying to troubleshoot this issue for the past few hours with no success. The ID of the logo element is 'Logo'. You can view the sit ...

Retrieving inline CSS value using jQuery

How do I retrieve the inline-css value of the second child within div #one using jQuery. <li id="one"> <h2>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Mollitia, velit!</h2> <div style="width: 1425px; height: 1080px ...

Header media query in CSS3 not functioning as expected

Currently, I have two separate style sheets for mobile and desktop versions. My intention is to default to the mobile style sheet. Upon examining my header, I have included the following: <link rel='stylesheet' media='all' href=&ap ...

What is the process for setting the opacity of the background in ::selection to 1?

Is it possible to have selected text with a solid background rather than a transparent one? Using opacity: 1 does not achieve the desired effect due to some standard override by the browser or other factors. ::-moz-selection { background: #fff; colo ...

The styling of divIcons in React Leaflet Material UI is not applied as expected

When using divIcon in React Leaflet to render a custom Material UI marker with a background color prop, I noticed that the background style is not being applied correctly when the marker is displayed in Leaflet. Below you can find the code for the project ...

Round corners, images in the background, gradients in the background, and compatibility with Internet Explorer versions 8 and

I've encountered an issue where my div with border radius, background gradient, and background image are working fine in FireFox but not displaying correctly in IE8 or IE10. In IE8, the gradient and background image work properly, but as soon as I app ...

Is it secure to use a unique, static HTML/CSS website?

As a web developer, I am currently working on hosting a Wordpress-website for a client. However, my frontend development skills have improved significantly and now I feel inspired to create a simpler and more customizable version on my own. This website i ...

Malfunctioning Line in Apple Safari Causing ReactJS Issues

I am encountering an issue with my <div className={`${classes.center} ${classes.or}`}>OR</div>. It appears that this problem is specific to Apple Safari only. The alignment on the right side seems to be broken, although it works fine on Google ...

Create the design shown below without using the <pre> tag

Creating this pattern using <pre> is straightforward, but I am interested in achieving the same result with <div> Is it possible to do this with margins? I attempted to use margins and was able to achieve success, although some patterns prove ...