Display a photo transitioning from black and white to color in a loading fashion, moving from left to right

Is there a way to enhance the clarity of the question's title?

I have an interesting effect where text starts off in grey color and then transitions to black using keyframes in CSS with the animate property.

I'm curious about how I can achieve a similar effect but with an image, transitioning from black and white to color from left to right.

Here is the code snippet:

    <div class="modal">
        <h1 id="testid" data-content="THIS&nbsp;IS&nbsp;A&nbsp;TEST">THIS&nbsp;IS&nbsp;A&nbsp;TEST</h1>
    </div>

And here is the corresponding CSS:

@-webkit-keyframes loading{
    from{max-width:0}
}

@-moz-keyframes loading{
    from{max-width:0}
}

@-o-keyframes loading{
    from{max-width:0}
}

@keyframes loading{
    from{max-width:0}
}

.modal {
background:#fff;
position:fixed;
top:0;
bottom:0;
left:0;
right:0;
z-index:9999999;
}

.modal h1 {
position:absolute;
left:50%;
top:50%;
margin-top:-15px;
margin-left:-125px;
font-size:30px;
text-align:center;
color:rgba(0,0,0,.2);
}

.modal h1:before {
content:attr(data-content);
position:absolute;
overflow:hidden;
color:#000;
max-width:100%;
-webkit-animation:loading 5s;
-moz-animation:loading 5s;
-o-animation:loading 5s;
-ms-animation:loading 5s;
animation:loading 5s;
}

You can view the code in action at this link: http://jsfiddle.net/5Vmnn/

Thank you for your help!

Answer №1

Perhaps you were considering something along these lines? Check out this Fiddle

While it's not exactly greyscale, the effect is quite similar.

UPDATE: Check out this version for Webkit with greyscale using -webkit-filter (still right-to-left...) Here

I opted to use opacity for your overlay, but the fundamental concept remains unchanged:

.modal {
 opacity: 0.8;
background:black;
z-index:9999999;
position: absolute;
left: 0;
top: 0;
max-width:0;
-webkit-animation:loading 5s;
-moz-animation:loading 5s;
-o-animation:loading 5s;
-ms-animation:loading 5s;
animation:loading 5s;
    width: 100%;
    height: 100%;
}

Answer №2

To create a dynamic animated GIF, I prefer using ImageMagick as it is much simpler.

Simply craft 5-10 images with different levels of black and white and color, then utilize ImageMagick to compile them into an animated GIF with just one line of code:

convert -delay 20 -loop 0 *.jpg animated.gif

If you desire a single loop, set loop=1, but for continuous looping like in the example, keep it at zero.

Experience the animated GIF here

For those unfamiliar with Photoshop, simply add a Hue Saturation layer and decrease the Saturation to zero for a monochrome effect. Then, use the Gradient Tool (G) to draw a horizontal line to mark the transition from black and white to color while holding Shift for precision. Save each variation as 1.jpg, 2.jpg, and so forth.

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

Testing Tools for AJAX Integration

Searching for AJAX testing resources. Are there any no-cost tools out there for conducting AJAX tests? Edit 2: Besides Firebug, are there any other tools available? ;) ...

Issue with camera boundaries in Three.js when using EffectComposer with an orthogonal camera is currently presenting inaccuracies

In reference to a previous question on Three.js, I have successfully created a scene with a "minimap" using an orthogonal camera rendering into a viewport. The minimap is displayed properly in the standard renderer. Now, I wanted to add postprocessing eff ...

How can I trigger an onclick event for a link automatically upon loading in Laravel?

I am presenting the link below: <a href="javascript:void(0)" onclick="xtenderSearchItem.modal_visibility = ! xtenderSearchItem.modal_visibility;">Request</a> My goal is for it to change the language of the page (which occu ...

What attribute should I utilize to ensure the image always takes priority over text when using @media queries?

resolution My goal is to have the image appear on top of the text when resizing the window, but maintain the appearance shown in the attached image when using a larger resolution. Below is the CSS code I am currently using: .section4 { text-align: cen ...

What exactly is the purpose of utilizing node js and can someone explain to me what constitutes a

After mastering HTML and CSS, I've started diving into JavaScript. However, I'm curious about Node.js. What exactly is it, why do I need it, and can you explain what a framework is in general? Sorry if these questions sound silly! ...

The integration of Bootstrap 5 causes jQuery to malfunction

I've been experimenting with creating a button that reveals input fields when clicked using the latest version of jQuery (3.7.1). Everything was running smoothly until I decided to add Bootstrap 5 tags for implementing a navigation bar later on. Surpr ...

Show validation messages using ng-messages depending on various conditions

Implementing angular ng-messages for validation message display Check out this code snippet: <ul ng-messages="formToValidate.fieldToValidate.$error" ng-messages-multiple> <li ng-message="pattern">Invalid pattern</li> <li ng-m ...

Creating a custom string subtype in TypeScript

I am currently working on developing a game called Risk using TypeScript and React hooks. This game is played on a map, so my first step was to design a MapEditor. The state of the Map Editor is as follows: export interface IMapEditorState { mousePos: ...

Different Approaches for Handling User Interactions in Angular Instead of Using the Deferred (Anti-?)Pattern

In the process of developing a game using Angular, I have implemented the following mechanics: An Angular service checks the game state and prompts a necessary user interaction. A mediator service creates this prompt and sends it to the relevant Angular c ...

Interpret HTML code through PHP

Is it a security or performance risk to configure the Apache web server to interpret all HTML files as PHP? Specifically, I am considering: AddType application/x-httpd-php .php .php3 .php4 .html I found myself in a situation where I needed to incorporate ...

In search of a new object value to update

Looking to update the value of a specific object key in an array? Here is the code snippet where I want to make this change. I only want to replace the value under Mon, not the entire array length. The key weekday will be provided dynamically. array = [ ...

Obtaining the current index in a list of strings using the map() function

Here is the code snippet I am working with: {words.map((word: string, index) => ( <Span key={index}> <Span> {word} </Span> </Span> ))} Currently, this code displays dif ...

To address the footer alignment on the jQuery Mobile webpage

My problem involves the footer on a mobile website designed with jQuery Mobile. After removing data-position="fix" from the footer, it is fixed in place. However, the page content is minimal, causing the footer to not align correctly with the desktop vers ...

Retrieving an HTML page from one location and automatically populating textboxes with preexisting values on the receiving end

I'm currently facing a dilemma. Here's the issue: I need to load an HTML page (let's call it test.html) when a button is clicked on another page (referred to as home page). The test.html page has input boxes that I want to populate with p ...

Toggling dropdown menus with conditional Jquery statements

I am experiencing some discomfort. :) I've been working on a calorie calculator that includes a dropdown for various dietary preferences. Currently, when a user clicks the button, the dropdown appears and disappears when clicking outside the button. ...

Incorporating video.js into an Angular website application

I've encountered a strange issue while attempting to integrate video.js into my angular app. <video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="300" height="264" poster="http://video-js.zenco ...

Concerned about encountering undefined values when using the `each` method

function getNewResponse(click, toElement, getParser) { $("body").on('change', click, function (event) { $(toElement).empty(); removeExistingDataFull(); $.ajax({ url: "../Controller/jsonParser.ph ...

Create a roster of numbers that are multiples using a systematic approach

Is the following code a functional way to return multiples of 5? function Mul(start,array,Arr) { Arr[start]=array[start]*5; if(start>array.length-2){ return Arr; } return Mul(start+1,array,Arr); } var numbers =[1,2,3,4,5,6 ...

Can you navigate to HTML files using Vue router?

Hey there! I'm currently utilizing VueJS along with the webpack template. I've got a variety of components that I can easily showcase with Vue Router. However, the testing framework utilized by my team is Robot Framework and we typically create a ...

rendering google charts using jade template

I am facing an issue while trying to display a google annotated chart on my jade project. I managed to successfully load a pie chart, but I am having trouble rendering a chart that requires the container element size to be explicitly defined. You can find ...