vue-image-compare2
Version:
Compare two images with a fancy slider
130 lines (113 loc) • 2.01 kB
CSS
.image-compare {
position: relative;
overflow: hidden;
margin: 0;
}
.after-name,
.before-name {
font-size: 1rem;
position: absolute;
bottom: 0;
overflow: hidden;
padding: 0.5rem 1rem;
white-space: nowrap;
text-overflow: ellipsis;
pointer-events: none;
background-color: white;
}
.after-name .size,
.before-name .size {
font-family: monospace;
font-size: 1.2rem;
margin-top: 2px;
color: gray;
}
.after-name {
z-index: 5;
left: 0;
border-top-right-radius: 0.75rem;
}
.before-name {
right: 0;
border-top-left-radius: 0.75rem;
}
.before-name .size {
text-align: right;
}
img {
display: block;
max-width: none;
}
.drop-zone {
font-size: 50px;
position: absolute;
z-index: 10;
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
pointer-events: none;
opacity: 0;
color: white;
background-color: rgba(black, 0.5);
}
.drop-zone.visible {
pointer-events: all;
opacity: 1;
}
.image-compare.full {
overflow: hidden;
flex: 1;
width: 100%;
height: 100%;
}
.image-compare.full img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: contain;
}
.wrapper,
.handle {
position: absolute;
top: 0;
bottom: 0;
}
.wrapper {
z-index: 1;
left: 0;
overflow: hidden;
width: 100%;
transform: translateZ(0);
will-change: width;
}
.handle {
z-index: 2;
width: 2px;
cursor: ew-resize;
transform: translateX(-50%) translateZ(0);
color: #fff;
background-color: currentColor;
will-change: left;
}
.handle-icon {
font-size: 2rem;
line-height: normal;
position: absolute;
top: 50%;
left: 50%;
color: currentColor;
}
.handle-icon.left {
padding-right: 10px;
transform: translate(-100%, -50%);
}
.handle-icon.right {
padding-left: 10px;
transform: translate(0, -50%);
}