Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Is it possible to invert an image using JS

Featured Replies

Very simple solution done with CSS transitions

http://jsfiddle.net/Nillervision/dhf57/

It requires no JS but two versions of the image

EDIT: This works only with hover. If you want it to change with onclick you will need javascript (easiest way is to change className property with js and add the transition to the new class with css)

Edited by Nillervision

CSS3 does this with its webkit transitions.

To keep it very simple to test this. Lets say you have a div id element named 'fade'. Or in your case you would have a background image on the div element to show one version of the image on hover that has been inverted from black to white.

 

<div id="fade"></div>

 

The CSS code:

 

#fade {
width:40px;
height:40px;
display:block;
background:#000;
}
#fade:hover {
background:#fff;
-webkit-transition: all 3s ease;
-moz-transition: all 3s ease;
-ms-transition: all 3s ease;
}

 

Hope this helps.

Edited by allen180

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.