Tips for preventing svg flickering when using css scaling

I am facing an issue where scaling a SVG using CSS results in flickering. Are there any modifications I can make to the CSS or SVG to eliminate this flickering problem? I have tried creating the SVG both with and without a mask in Illustrator, but the flickering persists when using CSS scale. Even scaling with gsap leads to the same issue.

.wrapper{
            max-width: 960px;
            margin: 0 auto;
            background-color: antiquewhite;
            padding: 250px;
        }
        .box{
            width: 200px;
            min-height: 200px;
            margin: 0 auto;
            background-color: aqua;
            transition: transform 2.5s;
            cursor: pointer;
            color: blueviolet;
            text-align: center; 
        }
       
       
       .box:hover{
            transform: scale(3);
            opacity: 1;    
        }
<div class="wrapper">
        <div class="box">
          <p>Hover Blue box to Zoom in</p>
            <?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 888.12 90.88">
  ... (SVG Path Data)
</svg>
</div>
</div>

Tried also to start with opacity set at zero, but it still flickers on scale

How to stop svg flickering with css scale?

Here is a link to see what happens in codePen:

https://codepen.io/atataylor/pen/OJqJajz

Answer №1

After numerous attempts to optimize the SVG, the transition is still causing the lines to become blurred. Interestingly, applying

shape-rendering="crispEdges"
to the svg element actually exacerbates the issue.

To tackle this problem, I created a text in Inkscape and converted it into a path. Then, I copied the path d attribute value to SvgPathEditor, where I set the number of decimals to 2 and chose "minify output." Finally, I constructed a mask for the horizontal lines.

.wrapper {
  max-width: 960px;
  margin: 0 auto;
  background-color: antiquewhite;
  padding: 250px;
}

.box {
  width: 200px;
  min-height: 200px;
  margin: 0 auto;
  background-color: aqua;
  transition: transform 2.5s;
  cursor: pointer;
  color: blueviolet;
  text-align: center;
}

.box:hover {
  transform: scale(3);
  opacity: 1;
}
<div class="wrapper">
  <div class="box">
    <p>Hover Blue box to Zoom in</p>
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 94 11">
      <defs>
        <mask id="m01">
          <rect width="94" height="11" fill="white" />
          <line transform="translate(0 1)" x2="94" stroke-width=".6" stroke="black" />
          <line transform="translate(0 2)" x2="94" stroke-width=".5" stroke="black" />
          <line transform="translate(0 3)" x2="94" stroke-width=".4" stroke="black" />
          <line transform="translate(0 4)" x2="94" stroke-width=".3" stroke="black" />
        </mask>
      </defs>
      <path mask="url(#m01)" d="M7.42 8.21H3.54L2.57 9.98H0L5.49.26h2.86l1.72 9.72h-2.38zm-2.94-1.76h2.61l-.59-3.74zm13.37 3.08q-.9.32-1.73.48-.83.16-1.57.16-1.96 0-3.13-1.07-1.17-1.07-1.17-2.85 0-1.17.37-2.19 . . .
     

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

Pair of div elements stacking order

In this scenario, there are two div blocks with different z-index values. The first block has a z-index of 0, while the second block has a z-index of -1. I am looking to display the text on top of everything within the block that has a z-index of -1. I hav ...

Angular 8 can sometimes cause CSS to become disorganized upon page load

In the process of developing my angular project, I've integrated pre-designed HTML templates. Implementing lazy loading for page loading has led to an issue where the CSS appears distorted, as shown in the attached gif image. https://i.sstatic.net/7UZ ...

Limit the ability to zoom in a webview application

I am facing an issue with my Android WebView app that is designed to load a specific URL and display it along with its links within the app. Despite setting the webpage size to 720px x 1280px using CSS to fit the screen of a Galaxy S3, I am encountering di ...

The width of each column in this dataset is variable and unknown

I need to organize a varying number of items into columns. The sizes of both the items and container are unknown, as well as how many columns will fit or what width they should be. I want the browser to arrange the items in as many columns as possible with ...

What is the best way to incorporate a single "X" close button to close individual div elements, allowing for the closure of one div with each click of the button?

Among these options in rectangles, each with a class of ('.caja'), the styling and database values are stored within this class for user selection. However, I am facing an issue where jQuery and CSS automatically close all div elements when the ...

Assistance with Collision Detection in HTML5 Canvas using JavaScript

Attempting to create a platformer game using HTML5 and the canvas feature. I managed to implement collision detection with rectangles, but encountered issues when adding multiple rectangles. I have a function that adds new objects to an array with attribut ...

A vertical line in Javascript extending upward from the base of an element

Is there a way to create a design where an infinite vertical line extends from the bottom of a circle (or in my case, a rectangle) without using css :after or pseudo-elements? I would like the line to be its own element and not limited by the restriction ...

Fade out when the anchor is clicked and fade in the href link

Is it possible to create fade transitions between two HTML documents? I have multiple HTML pages, but for the sake of example, let's use index.html and jobs.html. index.html, jobs.html Both pages have a menu with anchor buttons. What I am aiming to ...

Increase visibility, decrease visibility by utilizing ng-hide/ng-show and functions

As I implement the show more/show less feature, I am uncertain if achieving a smooth effect is feasible. However, I believe it's worth reaching out to this community for some creative ideas on how to make it possible. I have a list of dynamic links w ...

Ways to Conceal the Featured Column on a Broadleaf Website

I am in the process of creating an E-commerce website using the Broadleaf template. My objective is to eliminate the Featured column located on the right side of the website. How can I achieve this? ...

What is the best way to line up two forms side by side?

Looking to create a login view for a webpage with two forms (one for registration and one for login) aligned side by side. Initially attempted using a table, then tried using bootstrap form groups (rows and cols) without success. Finally, aligned them in t ...

Functionality of local data storage

I'm currently exploring the capabilities of the localStorage feature. Let's say I have a large JSON object stored using localStorage. I need to share this data with the testing team for review. However, if I try to display the stored data on an H ...

Creating an element that remains a consistent height despite zooming or resizing the window: A guide with HTML and CSS

Recently, I created a custom scrollbar but faced an issue with its width. Whenever I zoom in or out (Ctrl + mousewheel), the width (set to 10px) changes due to being in pixels. When switched to width: 1vw, it works well with zooming but gets affected by wi ...

Transforming ideas into digital reality

I am currently facing challenges in creating a website based on a specific design. The design was made using InDesign and the website is expected to be a single page with a width of 1280px. One of the main issues I'm encountering involves resizing, gi ...

When hovering over slick text, it becomes hidden because of non-responsive CSS. Are there any solutions to make it responsive?

I can't seem to get the on-hover dates to appear, even though they are rendered when inspecting the page. I suspect it could be related to a responsive CSS issue or class breaking. How can I resolve this? https://i.stack.imgur.com/jyEJb.png https:// ...

Enhancing the efficiency of a JavaScript smooth scrolling feature for numerous listed items

I have been experimenting with recreating the recent Apple Mac retrospective using only CSS and JavaScript to create a small timeline of projects. While I have successfully implemented the layout for the full-screen hero and the expand-on-hover effect, I a ...

Issue with Ajax when attempting to load new content into a div after submitting a form

After implementing the code below to submit a form and use ajax to load the action page into a div on the same page, I am encountering an issue where clicking submit results in a duplicate copy of the form appearing again. <script src="//ajax.googleapi ...

Having difficulty removing whitespace from JavaScript code

Struggling to align a div using Javascript on my professor's website to match the spacing of the rest of the site. Despite attempts at adjusting margins and following suggestions from other Stackoverflow.com threads (e.g. CSS: Center block but left al ...

Fetching data in VueJs before redirecting to a new page

Within the mounted function, I am creating an action that fetches data from a Rest API and populates my table in a Vue.js component mounted() { UserService.getProjects().then( (response) => { this.isProject = true; this.project ...

Tips for referencing the second class when two classes share the same name in Selenium WebDriver

I am trying to retrieve the text from the second "109-top-dark-grey-block ng-binding" class, which is currently null but will contain some text in the future. I have attempted using tabIndex and nth-child selectors, but neither have been successful. " < ...