Transitioning with CSS Scale may result in uneven edges

My current struggle lies with a preloader I designed. It features a simple mask effect that appears as follows:

(function() {
  'use strict';

  setTimeout(function() {
    document.body.className = 'loaded';
  }, 3000);
})();
#loader-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
}

#loader-wrapper .loader-background {
  position: fixed;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background-color: #000000;
}

#loader-wrapper .loader-background::after {
  content: '';
  position: absolute;
  left: 150px;
  bottom: 150px;
  border-radius: 100%;
  width: 150px;
  height: 150px;
  box-shadow: 0px 0px 0px 2000px #000000;
  -webkit-transition: all 3s;
  -moz-transition: all 3s;
  transition: all 3s;
}

.loaded #loader-wrapper {
  visibility: hidden;
}

.loaded #loader-wrapper .loader-background::after {
  -webkit-transform: scale(20);
  -moz-transform: scale(20);
  -ms-transform: scale(20);
  transform: scale(20);
}

.loaded #loader {
  opacity: 0;
  -webkit-transition: all 0.3s ease-out;
  transition: all 0.3s ease-out;
}

@-webkit-keyframes spin {
  0% {
    -webkit-transform: rotate(0deg);
    /* Chrome, Opera 15+, Safari 3.1+ */
    -ms-transform: rotate(0deg);
    /* IE 9 */
    transform: rotate(0deg);
    /* Firefox 16+, IE 10+, Opera */
  }
  100% {
    -webkit-transform: rotate(360deg);
    /* Chrome, Opera 15+, Safari 3.1+ */
    -ms-transform: rotate(360deg);
    /* IE 9 */
    transform: rotate(360deg);
    /* Firefox 16+, IE 10+, Opera */
  }
}
<h1>This content is visible when the circle exapnds</h1>
<div id="loader-wrapper">
<div id="loader"></div>
<div class="loader-background"></div>
</div>

The issue can be observed through this Codepen showcase:

https://codepen.io/r3plica/pen/rwLagV

(Please note that this investigation was conducted on Chrome browser)

Answer №1

When you take a small bitmap and scale it up, the edges tend to become jagged. However, if you reverse this process, the edges will appear smooth.

In this case, the original circle is initially rendered very small and then scaled up by 20 times its original size. The jagged edges that are visible are actually the pixels from the original rendering.

An updated technique involves using box-shadow for the masking effect. Similar to before, the key is to render at the largest size first and then gradually scale down over a period of 3 seconds.

(function() {
  'use strict';

  setTimeout(function() {
    document.body.className = 'loaded';
  }, 500);
})();
#loader-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
}

#loader-wrapper .loader-background {
  position: fixed;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  background-color: #000000;
}

#loader-wrapper .loader-background::after {
  content: "";
  position: absolute;
  border-radius: 100%;
  top: -750px;
  right: 0;
  width: 2000px;
  height: 2000px;
  box-shadow: 0 0 0 10000px #000000;
  transition: all 3s;
  transform: scale(0.1);
  /* Start off-screen */
}

.loaded #loader-wrapper {
  visibility: hidden;
}

.loaded #loader-wrapper .loader-background::after {
  transform: scale(1);
}
<h1>Updated text</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facilis eos modi expedita eius ab totam aspernatur fuga, rem assumenda deleniti?</p>

<div id="loader-wrapper">
  <div id="loader"></div>
  <div class="loader-background"></div>
</div>

The values provided may require adjustment to better suit your specific needs. For a full-screen wipe effect, you might need to use a larger box-shadow with a different ending radius compared to what is shown here.

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

Modify the shading of the mesh generated with the face3 method

I have utilized face 3 and three js to generate a mesh, but the expected color is not displaying correctly on the mesh. Below is the code snippet I used: var geometry = new THREE.Geometry(); var f = 0; for (var i = 0; i < data.real.length ...

Utilizing Bootstrap 4 cards in conjunction with a responsive next/image component

<div className="row align-items-center justify-content-center"> <div className="col-md-3 mt-3"> <div className="card bg-light"> <div className="card-img-top"> <N ...

"Interactive elements like dropdown menus and clickable buttons that transform the content of an HTML

My webpage includes three buttons that, when clicked, reveal hidden div elements containing forms. Here is the HTML code for the buttons: <button id="edituser" type="submit" onclick="toggle_visibility('c');" style="border:0;width:100px;margin ...

The hover effect is not resizing the button as expected

I attempted to create a similar effect like this: https://i.sstatic.net/hbiOS.gif As you can see, when the mouse hovers over the button, it has a scaling and fading white effect. I tried to achieve the same effect on my Bootstrap button by customizing m ...

Controlling icons and images in Django

I have a question regarding the best practice for managing media on my Django site. Unlike most questions that involve confusion with code snippets, this one concerns the dilemma faced by some web developers. Instead of storing all media content in a mod ...

The naming convention for CSS classes could be defined as follows: .sa-list li a > div{

As I dive into a CSS example, one particular section of code catches my eye: .sa-list li label > span, .sa-list li h3 > span, .sa-list li h4 > span, .sa-list li a > div{ position:relative; display:table-cell; vertical-align:middle; ...

How can you remove the border when an input is in focus on Chrome or Microsoft Edge?

I need to style an input field in a way that removes the black borders/frame that appear around it when clicked on in Chrome and MS Edge. Strangely, Firefox does not display this frame/border. How can I achieve this consistent styling across all browsers? ...

extract information from the HTML id attribute and assign it to a PHP variable using the GET method

After reviewing numerous examples, I am still unable to retrieve the value from the ID attribute in my input element. This identifier is crucial for deleting records from the database, but my attempts with Get method have been unsuccessful. <?php ...

Ways to collect email address or name from an email message

Suppose I send an email to someone with a link at the bottom. The text of the link might be something like click me. When the user clicks on this link, they will be directed to a webpage. On this webpage, a message saying "Thank you" will be displayed a ...

Adapt the CSS based on different screen sizes

I am currently developing a mobile application using angularjs and the ionic framework. My application is intended for both tablet and mobile versions. I have encountered an issue where I cannot use the same CSS for both the tablet and mobile versions. Is ...

Aligning a single component in the center vertically with the appbar positioned at the top of the screen using Material

As a beginner with material UI, I am facing challenges in centering a component both horizontally and vertically on my screen while including an AppBar for navigation at the top. While I have come across solutions like this example using a grid system, i ...

Launch Bootstrap 4 Modal using JavaScript with just a simple click on a hyperlink

My goal is to trigger a modal to open when a link is clicked, but unfortunately I am unable to modify the HTML of the link itself. The only thing I can change is the href attribute. For example: <a href="#Modal">Open modal</a> I am not able ...

Introducing the new and improved SweetAlert 2.0, the ultimate solution for

I am currently utilizing SweetAlert2.0, known as "This One" <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> It is functioning properly; however, I would like to display a table, div, or HTML element within this swe ...

What is the best way to create a shaking image animation using React Native?

I am trying to create a shaking image animation in React Native when a TouchableOpacity is pressed. So far, I have implemented an animated image with the following code: const backgroundImage = require('./components/images/baby-sleep.jpg') cla ...

Hidden beneath the content div lies the secretive footer div

I am experiencing an issue with a webpage that is working in IE7 but not in IE8; Here is the HTML code: <div class="content"> <div class="inner_content"> <div class="column"> <div class="widget"> ...

Having problems with loading @font-face in Ionic Framework Android app build?

While working on an app in Ionic Framework, I encountered a peculiar issue. https://i.stack.imgur.com/xk8uD.png In my Ionic Framework application, I am importing @font-face and running the app on an Android device (Galaxy SIII). Strangely, the font (Mont ...

The fixed table header is misaligned with the body columns' width

I was looking for a way to add a vertical scrollbar to my table, and I ended up wrapping the entire table in a div. The result was that the table head was fixed in position. Is there a simpler method to include a scrollbar in a table without affecting the ...

When attempting to use the .split method, an error is thrown stating that addEventListener is not

I'm attempting to create a table that automatically fills in the next input when I select options from MySQL. However, when I run this code, I get an error saying "addEventListener is not a function." I'm not very familiar with JavaScript, so I&a ...

Change the <base> element programmatically during server-side rendering

Searching for a way to obtain the base URL for an HTML page, so that relative URL requests from the browser utilize that base. If you are looking for answers, check out this link: Defining root of HTML in a folder within the site root folder When serving ...

Troubleshooting issues with mail subscriptions using Ajax and PHP

My Idea for Implementation I successfully set up a subscription form using PHP initially. However, I wanted to enhance the user experience by implementing an Ajax feature that would display a nice image and a "thank you" message without reloading the pag ...