Skip to content

Instantly share code, notes, and snippets.

@csssecrets
Forked from LeaVerou/dabblet.css
Last active July 31, 2023 01:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 20 You must be signed in to fork a gist
  • Save csssecrets/b7e7fef7dcf9a7161a51 to your computer and use it in GitHub Desktop.
Save csssecrets/b7e7fef7dcf9a7161a51 to your computer and use it in GitHub Desktop.
Interactive image comparison - with CSS resize
/**
* Interactive image comparison - with CSS resize
*/
.image-slider {
position:relative;
display: inline-block;
}
.image-slider > div {
position: absolute;
top: 0; bottom: 0; left: 0;
width: 50%;
max-width: 100%;
overflow: hidden;
resize: horizontal;
}
.image-slider > div:before {
content: '';
position: absolute;
right: 0; bottom: 0;
width: 12px; height: 12px;
padding: 5px;
background: linear-gradient(-45deg, white 50%, transparent 0);
background-clip: content-box;
cursor: ew-resize;
-webkit-filter: drop-shadow(0 0 2px black);
filter: drop-shadow(0 0 2px black);
}
.image-slider img {
display: block;
user-select: none;
}
<div class="image-slider">
<div><img src="http://csssecrets.io/images/adamcatlace-before.jpg" alt="Before" /></div>
<img src="http://csssecrets.io/images/adamcatlace.jpg" />
</div>
// alert('Hello world!');
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment