sticker pull off effect with css - css

I'm trying to create a sticker pull off effect with css.
For that I found this example: https://codepen.io/patrickkunka/pen/axEgL
Now I have three problems.
I'm using an image and not only colors.
The peeling effect is way to far in the example
Because I'm using an image, I can't move it around.
Now let me show the problems with some code:
.test-sticker {
/*
.sticker:hover .sticky{
transform: rotate(10deg);
}
*/
}
.test-sticker .anim750 {
transition: all 750ms ease-in-out;
}
.test-sticker .sticker {
position: relative;
width: 180px;
height: 180px;
margin: 0 auto;
backface-visibility: hidden;
}
.test-sticker .sticker .sticky {
transform: rotate(-125deg);
}
.test-sticker .sticker .sticky {
position: absolute;
top: 0;
left: 0;
width: 180px;
height: 180px;
}
.test-sticker .sticker .reveal .circle {
font-family: 'helvetica neue', arial;
font-weight: 200;
line-height: 140px;
text-align: center;
cursor: pointer;
}
.test-sticker .sticker .reveal .circle {
background: purple;
}
.test-sticker .sticker .circle_wrapper {
position: absolute;
width: 180px;
height: 180px;
left: 0px;
top: 0px;
overflow: hidden;
}
.test-sticker .sticker .circle {
position: absolute;
width: 140px;
height: 140px;
margin: 20px;
border-radius: 999px;
}
.test-sticker .sticker .back {
height: 10px;
top: 30px;
}
.test-sticker .sticker .back .circle {
margin-top: -130px;
background-color: green;
}
.test-sticker .sticker .front {
height: 150px;
bottom: 0;
top: auto;
-webkit-box-shadow: 0 -140px 20px -140px rgba(0, 0, 0, 0.3);
}
.test-sticker .sticker .front .circle {
margin-top: -10px;
background: url("https://upload.wikimedia.org/wikipedia/commons/9/93/Wordpress_Blue_logo.png");
background-size: 140px 140px;
transform: rotate(-235deg);
}
.test-sticker .sticker:hover .back {
height: 90px;
top: 110px;
}
.test-sticker .sticker:hover .back .circle {
margin-top: -50px;
}
<div class="test-sticker">
<div class="wrapper">
<div class="sticker">
<div class="reveal circle_wrapper">
<div class="circle"></div>
</div>
<div class="sticky">
<div class="front circle_wrapper">
<div class="circle"></div>
</div>
</div>
<div class="sticky anim750">
<div class="back circle_wrapper anim750">
<div class="circle anim750"></div>
</div>
</div>
</div>
</div>
</div>
How do I get the greed circle just about 50% and not like now 80%?
Is there a fancy way to get the purple circle extended the same way like the green one? so when I hover over the image, I want to see the back of the sticker, which is white at the end.

Related

How to directional hover effect to a filter?

I am trying to add a sliding hover filter effect to image. My original filter is grayscale(1).
So I need to the filter to transition with direction instead of the Slider overlay effect to have it to become colored: "grayscale(0)".
Basically i want the filter to be affected.
Is it possible?
Thank you in advance.
* {
box-sizing: border-box;
}
body {
background: #fefefe;
color: #333;
font: 14px/1.5 "Fira Sans", sans-serif;
}
h1 {
font-size: 2.5rem;
font-weight: 300;
margin: 1.5em 0.5rem 1em;
text-align: center;
}
.container {
margin: 0 auto;
padding: 2rem;
max-width: 1200px;
}
.row {
display: flex;
}
.col {
color: #fff;
flex: 1 1 auto;
min-height: 260px;
position: relative;
}
.col h2 {
font-weight: 300;
font-size: 1.33333rem;
line-height: 1.25;
margin: 0;
position: absolute;
bottom: 1.5rem;
right: 1.5rem;
z-index: 0;
}
.col:nth-child(2) {
min-width: 20%;
}
.col:nth-child(4) {
min-width: 33%;
}
.col:nth-child(3)+.col:nth-child(3) {
min-width: 50%;
}
.img-container {
background: #0f0523 50% 50%/cover;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transition: 1s;
transform-origin: bottom right;
filter: grayscale(1);
}
.img-container::before {
background: linear-gradient(transparent, rgba(67, 17, 51, 0.5), #000320);
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.col:hover .photo-container {
transform: scale(1.25);
}
.slide {
background: rgba(0, 0, 0, 0.4);
padding: 0 1.5rem;
}
/* THE EFFECT */
.col {
overflow: hidden;
position: relative;
}
.slide {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transition: all 0.275s ease-in-out, visibility 0s 0.275s;
visibility: hidden;
will-change: transform;
transform: translateY(100%);
}
.row:hover~.row .slide {
transform: translateY(-100%);
}
.row:hover .slide {
transform: translateX(100%);
}
.row:hover .col:hover~.col .slide {
transform: translateX(-100%);
}
.row:hover .col:hover .slide {
transform: none;
visibility: visible;
transition-delay: 0s;
}
<div class="container">
<div class="row">
<div class="col">
<div class="img-container" style="background-image:url(https://source.unsplash.com/600x250/?sig=80);"></div>
<h2>1 </h2>
<div class="slide"></div>
</div>
</div>
<div class="row">
<div class="col">
<div class="img-container" style="background-image:url(https://source.unsplash.com/600x250/?sig=212);"></div>
<h2>2 </h2>
<div class="slide"></div>
</div>
<div class="col">
<div class="img-container" style="background-image:url(https://source.unsplash.com/600x250/?sig=242);"></div>
<h2>3 </h2>
<div class="slide"></div>
</div>
Here is an idea using mask where you can animate the mask-position. You can also rely on pseudo element for the image to avoid extra elements. The trick is to have two images above each other and we adjust the masking on the top to show the bottom one.
I removed the text to keep only the code related to the filter effect:
* {
box-sizing: border-box;
}
body {
background: #fefefe;
}
.container {
margin: 0 auto;
padding: 2rem;
max-width: 1200px;
}
.row {
display: flex;
}
.col {
color: #fff;
flex: 1 1 auto;
min-height: 260px;
position: relative;
}
.img-container {
background-size:0 0;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.img-container::before,
.img-container::after {
content: "";
background-image: inherit;
background-size:cover;
background-position:center;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.img-container::before {
filter: grayscale(1);
}
.img-container::after {
transition: all 0.275s ease-in-out, visibility 0s 0.275s;
visibility: hidden;
-webkit-mask: linear-gradient(#fff,#fff);
-webkit-mask-size: 200% 200%;
-webkit-mask-position:left 0 bottom 200%;
-webkit-mask-repeat: no-repeat;
mask: linear-gradient(#fff,#fff);
mask-size: 200% 200%;
mask-position:left 0 bottom 200%;
mask-repeat: no-repeat;
}
.row:hover~.row .img-container::after {
-webkit-mask-position:left 0 top 200%;
mask-position:left 0 top 200%;
}
.row:hover .img-container::after {
-webkit-mask-position:right 200% top 0;
mask-position:right 200% top 0;
}
.row:hover .col:hover~.col .img-container::after {
-webkit-mask-position:left 200% top 0;
mask-position:left 200% top 0;
}
.row:hover .col:hover .img-container::after {
visibility: visible;
transition-delay: 0s;
-webkit-mask-position:0 0%;
mask-position:0 0%;
}
<div class="container">
<div class="row">
<div class="col">
<div class="img-container" style="background-image:url(https://picsum.photos/id/1012/800/800);"></div>
</div>
</div>
<div class="row">
<div class="col">
<div class="img-container" style="background-image:url(https://picsum.photos/id/1014/800/800);"></div>
</div>
<div class="col">
<div class="img-container" style="background-image:url(https://picsum.photos/id/16/800/800);"></div>
</div>
</div>
</div>
mask in this case works the same way as background so you can check this question/answer to get more details about the calculation: Using percentage values with background-position on a linear gradient
Changing mask with background to better see the trick:
* {
box-sizing: border-box;
}
body {
background: grey;
}
.container {
margin: 0 auto;
padding: 2rem;
max-width: 1200px;
}
.row {
display: flex;
}
.col {
color: #fff;
flex: 1 1 auto;
min-height: 260px;
position: relative;
}
.col:nth-child(2) {
min-width: 20%;
}
.col:nth-child(4) {
min-width: 33%;
}
.col:nth-child(3)+.col:nth-child(3) {
min-width: 50%;
}
.img-container {
background-position:center;
background-size:0 0;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transition: 1s;
transform-origin: bottom right;
}
.img-container::before {
background: inherit;
background-size:cover;
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
filter: grayscale(1);
}
.img-container::after {
content:"";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transition: all 0.275s ease-in-out, visibility 0s 0.275s;
visibility: hidden;
background: linear-gradient(#fff,#fff);
background-size: 200% 200%;
background-position:left 0 bottom 200%;
background-repeat: no-repeat;
}
.col {
overflow: hidden;
position: relative;
}
.row:hover~.row .img-container::after {
background-position:left 0 top 200%;
}
.row:hover .img-container::after {
background-position:right 200% top 0;
}
.row:hover .col:hover~.col .img-container::after {
background-position:left 200% top 0;
}
.row:hover .col:hover .img-container::after {
visibility: visible;
transition-delay: 0s;
background-position:0 0%;
}
<div class="container">
<div class="row">
<div class="col">
<div class="img-container" style="background-image:url(https://picsum.photos/id/1012/800/800);"></div>
</div>
</div>
<div class="row">
<div class="col">
<div class="img-container" style="background-image:url(https://picsum.photos/id/1014/800/800);"></div>
</div>
<div class="col">
<div class="img-container" style="background-image:url(https://picsum.photos/id/16/800/800);"></div>
</div>
</div>
</div>
Basically the white color is the visible part of the image, so sliding it will make our image without filter visible.

CSS rotation create unwanted border around divs

I was trying to do the pie chart based on three divs. However, there's always some unwanted border around the divs. Also, they'll expand or shrink while zooming in and out.
Try many ways on other similar questions' solutions. Still can't work.
codepen link https://codepen.io/DavidLee0314/pen/PXWzYJ?editors=1100
* {
width: 100%;
height: 100%;
position: absolute;
margin: 0px;
padding: 0px;
}
.pie {
left: 40%;
top: 30%;
width: 174px;
height: 174px;
border-radius: 100%;
overflow: hidden;
display: flex;
justify-content: center;
font-size: 0px;
white-space: nowrap;
}
.pie .small-box {
width: 100%;
height: 100%;
}
.pie .grey {
transform: translateX(-50%);
background-color: #f3f5f2;
}
.pie .green {
transform: translateX(25%);
background-color: #222;
}
.pie .change {
transform-origin: left center 0;
transform: translateZ(0) scale(1, 1) translateX(50%) rotate(0deg);
background-color: #f3f5f2;
}
<div class="pie">
<div class="small-box green"></div>
<div class="small-box grey"></div>
<div class="small-box change"></div>
</div>
just use this at *:
Border: none:
* {
width: 100%;
height: 100%;
position: absolute;
margin: 0;
padding: 0;
border: none;
}
.pie{
left: 40%;
top: 30%;
width: 174px;
height: 174px;
border-radius: 100%;
overflow: hidden;
display: flex;
justify-content: center;
font-size: 0;
white-space: nowrap;
}
.small-box {
width: 100%;
height: 100%;
}
.grey {
transform: translateX(-50%);
background-color: #f3f5f2;
}
.green {
transform: translateX(25%);
}
.change {
transform-origin: left center 0;
transform: translateZ(0) scale(1.0, 1.0) translateX(50%) rotate(0deg);
background-color: #f3f5f2;
}
<div class="pie">
<div class="small-box green"></div>
<div class="small-box grey"></div>
<div class="small-box change"></div>
</div>

Animation Text Duration

I've tried many things however, I cannot control the animation duration. Basically, I would like to show my every animated text for 2-3 seconds. My text is animated too fast. How can I fix that? Note: the place of the animated text is not important.
.wrapper {
position: absolute;
top: 35%;
left: -4%;
padding: 2em 5em;
color: #000;
font-weight: 700;
font-size: 150%;
}
.wrapper p {
height: 60px;
float: left;
margin-right: 0.3em;
}
.wrapper b {
float: left;
overflow: hidden;
position: relative;
height: 30px;
top: 5px;
}
.wrapper .animationText {
display: inline-block;
color: #ac1101;
position: relative;
white-space: nowrap;
top: 0;
left: 0;
animation: move 7s;
animation-iteration-count: infinite;
animation-delay: 2s;
}
#keyframes move {
0% {
top: 0px;
}
20% {
top: -50px;
}
40% {
top: -100px;
}
60% {
top: -150px;
}
80% {
top: -200px;
}
}
<div class="wrapper">
<p>Some text here</p>
<b>
<div class="animationText">
anime text 1<br>
anime text 2
</div>
</b>
</div>
You can try this:
.wrapper {
position: absolute;
top: 35%;
left: -4%;
padding: 2em 5em;
color: #000;
font-weight: 700;
font-size: 150%;
}
.wrapper p {
height: 60px;
float: left;
margin-right: 0.3em;
}
.wrapper .b {
float: left;
overflow: hidden;
position: relative;
height: 30px;
top: 5px;
}
.wrapper .animationText {
display: inline-block;
color: #ac1101;
position: relative;
white-space: nowrap;
top: 0;
left: 0;
animation: move 3s;
animation-iteration-count: infinite;
animation-delay: 2s;
}
#keyframes move {
0%,30% {
top: 0%;
}
60%,100% {
top:-100%;
}
}
<div class="wrapper">
<p>Some text here</p>
<div class="b">
<div class="animationText">
anime text 1<br> anime text 2
</div>
</div>
</div>
Try adjusting animation-delay longer.

Flatten a Responsive CSS3 Triangle

I've created a responsive CSS3 triangle using the following guide.
GUIDE
The problem I now face is that I want to decrease its height. So it's not a 90-degree triangle but rather, I want to adjust its height to for example 30 pixels whilst maintaining a skewed triangle shape as well as it's responsiveness.
Here is what I have so far:
p {
margin: 0;
}
body {
background: black;
}
.container {
width: 50%;
margin: 0 auto;
}
.item {
background: white;
}
.tr {
overflow: hidden;
width: 100%;
position: relative;
padding-bottom: 100%;
}
.tr:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 120%;
height: 100%;
background: white;
transform-origin: top right;
transform: rotate(45deg);
}
<div class="container">
<div class="item">
<h1>Some Content</h1>
<p>Dummy Content</p>
</div>
<div class="tr"></div>
</div>
I tried experimenting with the perspective transform but with no luck.
You can scale the element to whatever ratio you want. I've compressed the triangle in my code by 2. Just use transform: scale(1, 0.5) rotate(45deg);
Note: The order of transformations will do matter. The result of
transform: rotate(45deg) scale(1, 0.5); is different from transform: scale(1, 0.5) rotate(45deg);
p {
margin: 0;
}
body {
background: black;
}
.container {
width: 50%;
margin: 0 auto;
}
.item {
background: white;
}
.tr {
overflow: hidden;
width: 100%;
position: relative;
padding-bottom: 100%;
}
.tr:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 120%;
height: 100%;
background: white;
transform-origin: top right;
transform: scale(1, 0.5) rotate(45deg)
}
<div class="container">
<div class="item">
<h1>Some Content</h1>
<p>Dummy Content</p>
</div>
<div class="tr"></div>
</div>
Answer by spooky daimon is way more intuitive, go for that one. Just to show the possibilities, you can also skew the pseudo element and adapt rotation as well as translation.
p {
margin: 0;
}
body {
background: black;
}
.container {
width: 50%;
margin: 0 auto;
}
.item {
background: white;
}
.tr {
overflow: hidden;
width: 100%;
position: relative;
padding-bottom: 100%;
}
.tr:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 120%;
height: 100%;
background: white;
transform-origin: top right;
transform: translate(25%) rotate(30deg) skew(-30deg);
}
<div class="container">
<div class="item">
<h1>Some Content</h1>
<p>Dummy Content</p>
</div>
<div class="tr"></div>
</div>

How can I make another skew container inside a skewed parent container using css

I am creating a simple layout using skews and my layout is like this:
And what I desired is something like this:
My problem is I can't make another div with skew inside the parent container.
Here's my CSS and HTML:
/*** VCONTENT ***/
#v-container {
position: relative;
background: #000;
}
#homepage-content-banner {
margin-top: 50px;
margin-bottom: 90px;
position: relative;
text-align: center;
z-index: 0;
background: #000;
}
#homepage-content-banner h1 {
font-family: times new roman;
color: #fff;
font-size: 80px;
margin-top: 35%;
}
#homepage-banner-images {
background-image: url('../images/top-banner-full.png');
background-repeat: no-repeat;
position: relative;
padding-left: 0px;
padding-right: 0px;
max-width: 100%;
max-height: 100%;
background-size: 100%;
height: 950px;
min-height: 950px;
margin-bottom: 150px;
}
#scroll-bottom {
color: #fff;
margin-top: 16%;
font-family: blueHighway;
}
#scroll-bottom:hover {
cursor: pointer;
color: #FFF100;
}
#homepage-about-us {
height: 300px;
position: relative;
width: 100%;
padding-left: 0px;
padding-right: 0px;
background: #fff;
}
#homepage-about-us::before {
content: '';
width: 100%;
height: 100%;
position: absolute;
background: inherit;
z-index: 0;
bottom: 0;
transform-origin: left top;
transform: skewY(-10deg);
}
<div id="v-container">
<div class="container-fluid" id="homepage-content-banner">
<div class="row">
<div class="col-md-12" id="homepage-banner-images">
<h1 class="headline">EVERYTHING IN THE WORLD IS<br />UNDER THE SAME SKY</h1>
<div id="scroll-bottom">
<h4>SCROLL</h4>
<div class="fa fa-long-arrow-down fa-2x"></div>
</div>
</div>
</div>
</div>
<div class="container-fluid" id="homepage-about-us">
<div class="inner-line">
<div class="img"></div>
</div>
</div>
</div>
Can you help me with this?
You can create a second item with skewY with ::after:
/*** VCONTENT ***/
#v-container {
position: relative;
background: #000;
}
#homepage-content-banner {
margin-top: 50px;
margin-bottom: 90px;
position: relative;
text-align: center;
z-index: 0;
background: #000;
}
#homepage-content-banner h1 {
font-family: times new roman;
color: #fff;
font-size: 80px;
margin-top: 35%;
}
#homepage-banner-images {
background-image: url('../images/top-banner-full.png');
background-repeat: no-repeat;
position: relative;
padding-left: 0px;
padding-right: 0px;
max-width: 100%;
max-height: 100%;
background-size: 100%;
height: 950px;
min-height: 950px;
margin-bottom: 150px;
}
#scroll-bottom {
color: #fff;
margin-top: 16%;
font-family: blueHighway;
}
#scroll-bottom:hover {
cursor: pointer;
color: #FFF100;
}
#homepage-about-us {
height: 300px;
position: relative;
width: 100%;
padding-left: 0px;
padding-right: 0px;
background: #fff;
}
#homepage-about-us::before {
content: '';
width: 100%;
height: 100%;
position: absolute;
background: inherit;
z-index: 0;
bottom: 0;
transform-origin: left top;
transform: skewY(-10deg);
}
#homepage-about-us::after {
content: '';
width: 100%;
height: 100%;
position: absolute;
background: yellow;
z-index: 0;
bottom: 0;
transform-origin: left top;
transform: skewY(-10deg);
}
<div id="v-container">
<div class="container-fluid" id="homepage-content-banner">
<div class="row">
<div class="col-md-12" id="homepage-banner-images">
<h1 class="headline">EVERYTHING IN THE WORLD IS<br />UNDER THE SAME SKY</h1>
<div id="scroll-bottom">
<h4>SCROLL</h4>
<div class="fa fa-long-arrow-down fa-2x"></div>
</div>
</div>
</div>
</div>
<div class="container-fluid" id="homepage-about-us">
<div class="inner-line">
<div class="img"></div>
</div>
</div>
</div>

Resources