Insert animation into shaped div - javascript

I must admit I'm less than a genius in CSS... To practice, I'm creating an animation that simulates a beer glass.
For the moment, looking at some examples, I've achieved the desired animation:
http://jsfiddle.net/yfb1fo8c/1/
And the shape I want:
#liquid {
background: black;
border-bottom: 500px solid #e39700;
border-left: 80px solid transparent;
border-right: 80px solid transparent;
width: 300px;
color: #fff8eb;
position: absolute;
clip:auto;
overflow:hidden;
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
}
But when I try to merge both ideas my shape totally crashes, or is not animated: http://jsfiddle.net/ogpqj2kr/2/
Any ideas?

Is this what you want : http://jsfiddle.net/Paf_Sebastien/cqa7rfu7/ ?
(Sorry I'm not giving more details as I had to change a lot of stuff. Basically, your 'cup' had no height so you didn't see the waves. I did more changes anyway.)
Here's your new CSS :
body {
padding: 0;
margin: 0 10px;
background: black;
}
#foam {
margin-top: 20px;
background: white;
width: 460px;
height: 100px;
z-index:1;
}
#liquid {
background: #000;
width: 460px; height: 500px;
position: relative;
clip:auto;
overflow:hidden;
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-o-transform: rotate(180deg);
z-index:2;
background-image:
-webkit-gradient(
linear,
left bottom,
left top,
color-stop(0, rgb(0,50,150)),
color-stop(0.50, rgb(0,150,255))
);
}
#liquid:before {
content: '';
position: absolute;
top: 0; left: 0;
width: 0;
height: 0;
border-style: solid;
border-width: 500px 80px 0 0;
border-color: #000000 transparent transparent transparent;
z-index: 10;
}
#liquid:after {
content: '';
position: absolute;
top: 0; right: 0;
width: 0;
height: 0;
border-style: solid;
border-width: 0 80px 500px 0;
border-color: transparent #000000 transparent transparent;
z-index: 10;
}
.wave{
bottom:0;
background:#fff;
display:inline-block;
height:10%;
width:10px;
position:absolute;
-webkit-animation-name: dostuff;
-webkit-animation-duration: 3s;
-webkit-animation-iteration-count: infinite;
-webkit-transition-timing-function: ease-in-out;
z-index:3;
}
#-webkit-keyframes dostuff{
0%, 100% {
height:10%;
}
50% {
height:20%;
}
}

the problem are those borders that you are using, it push the content and that's why you cant see your animation, is not that is broken it's that you can only see the border.
I recommend you to use a wrapper, find a proper technique to shape that wrapper and then insert inside your liquid template.
I take your code and update to this example. First i rotate the wrapper into 45deg using transform: rotate(45deg); and then i rotate the element in the opposite angle: transform: rotate(-45deg); for compensate transformation on the wrapper.
You can achieve this behavior in different ways but try to use transform or border-radius, even box-shadow, any element that doesn't push the inner
content
In this presentation you can find several shapes that you can achieve using border-radius and combine them with transforms like i did rotating the wrapper and doing the opposite with the inner element
Update:
Fixed working example, wasn't importing jQuery correctly

Related

how to make an interactive button that creates a semicircle around it when clicked

So I want to create a button that would go in the bottom of my screen and create a semicircle around it with more buttons inside when clicked. I've tried adjusting the CSS but Im not able to come up with a solution. Do you guys know a way to do it? I came across this codepen ("https://codepen.io/jet/pen/LwiGu"), which is almost exactly what I want, instead of creating a whole circle around it, it would create a semicircle around the top. I've attached an image for you guys to understand it better.
var items = document.querySelectorAll('.menuItem');
for(var i = 0, l = items.length; i < l; i++) {
items[i].style.left = (50 - 35*Math.cos(-0.5 * Math.PI - 2*(1/l)*i*Math.PI)).toFixed(4) + "%";
items[i].style.top = (50 + 35*Math.sin(-0.5 * Math.PI - 2*(1/l)*i*Math.PI)).toFixed(4) + "%";
}
document.querySelector('.center').onclick = function(e) {
e.preventDefault(); document.querySelector('.circle').classList.toggle('open');
}
#import "https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css";
body {
/* Image source: http://wallbase.cc/wallpaper/718405 */
/* Excuse the base64 mess, imgur blocked the hotlinked image and this seemed like the fastest solution */
background: cornflowerblue url(" data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAoCAYAAABOzvzpAAAACXBIWXMAAAsTAAALEwEAmpwYAAAOlUlEQVRo3k2aTWLj2o6DP5BHTt7dUk97C73/dbyySPSAlOoOXE7slC3+gQCO9L//839WiAyICDIAQYQAw/7bbtr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bc2giz/qUphLvCdPu6xkhvx5+2XM218G17Xuf4LTHcM2eu0BOj+jJf7k9Wp+PnWuSu3vFz/D9qapf7Y+hnnXa/ZKf14EaDPjb6o+3/bgzdvzrPqFVe8vE7jVB7zVQJQ89zmF9aEXP7t/S2vUtTvbc9NDi2JzeTrjiOQEcq7zXU8yR4qXeo3Lx3UTcC3zlSXIvjPRukBf03g3Cu0L7uUVmlfjaVo8QClp+zKO3E+jx5QNzL5Mq9Sq9FVLP6Y7X0Q2NI7vcf3z7UWL1r8elnlFinCRF44xZi7nOFOJW75H5sNWqeOVtvetxtsK0+3M/wzP/bMk1GPAebq7E9O42r+S1h5kNURlwKWZ2O8YzVM1nxJqq7xfufQQFfEN7PM2r3Ydseezr25z1nMKgXJ4Qo0ifLhiStH6fg3o8yH+1d/+78vwNnvUx1A0FR3vs9DCZ0ekNe4fW698/tlmPO1zbN7SXq/fgwzrKuYZpi/fmqdy2rnzMz353xFjTgzu5p0PB3MzUvfejadZ10VRoZ/25gWtI0d+7VvgXlX4MlL+z7+U9/w/sgwZKH+EVWgAAAABJRU5ErkJggg==") no-repeat fixed;
background-size: cover;
}
a {
font-size: 14px;
text-decoration: none;
outline: 0;
}
.circle,
.ring {
height: 256px;
position: relative;
width: 256px;
}
.circle {
margin: 0 auto;
}
.ring {
background-color: rgba(0,0,0,0.5);
border-radius: 50%;
opacity: 0;
-webkit-transform-origin: 50% 50%;
-moz-transform-origin: 50% 50%;
transform-origin: 50% 50%;
-webkit-transform: scale(0.1) rotate(-270deg);
-moz-transform: scale(0.1) rotate(-270deg);
-transform: scale(0.1) rotate(-270deg);
-webkit-transition: all 0.4s ease-out;
-moz-transition: all 0.4s ease-out;
transition: all 0.4s ease-out;
}
.open .ring {
opacity: 1;
-webkit-transform: scale(1) rotate(0);
-moz-transform: scale(1) rotate(0);
transform: scale(1) rotate(0);
}
.center {
background-color: rgba(255,255,255,0.3);
border-radius: 50%;
border: 2px solid #ffffff;
bottom: 0;
color: white;
height: 80px;
left: 0;
line-height: 80px;
margin: auto;
position: absolute;
right: 0;
text-align: center;
top: 0;
width: 80px;
-webkit-transition: all 0.4s ease-out;
-moz-transition: all 0.4s ease-out;
transition: all 0.4s ease-out;
}
.open .center {
border-color: #aaaaaa;
}
.menuItem {
border-radius: 50%;
color: #eeeeee;
display: block;
height: 40px;
line-height: 40px;
margin-left: -20px;
margin-top: -20px;
position: absolute;
text-align: center;
width: 40px;
}
<div class="circle">
<div class="ring">
</div>
</div>
[menu mockup][1]
[1]: https://i.stack.imgur.com/GR419.png
If i understand your desire correctly, then all you'd have to change is this:
The .ring currently has height&width 256px, change that if you want it bigger/smaller.
Now re-position the .ring so that it is aligned with the bottom of its container. You do that by setting a negative bottom of exactly half the .rings height (so something like bottom: -128px;).
Now you have to decide how many icons you need on there (there used to be 8 buttons in your source, but now that we clipped it, there is only 4 visible).
Now, adjust the 2 javascript lines (the ones with ...Math.PI... in it) to account for
(A) the amount of icons you want and
(B) the fact that you only want to populate the upper half of the .ring
The 2 Math.PI lines (which set the position of each individual button, aren't complicated but how you have to change them depends entirely on how big you're making the thing, and how many button you want to place on it - so i cannot really provide an example without knowing that.

Menu open and close animation

I have problem, when I'm opening menu I need animation like this:
#keyframes opening {
from {
clip-path: circle(0% at 5%, 10%)
}
to {
clip-path: circle(100%)
}
}
#keyframes closing {
from {
clip-path: circle(100%)
}
to {
clip-path: circle(0% at 5%, 10%)
}
}
On my menu
.menu {
position: fixed;
height: 100vh;
width: 100vw;
top: 0;
background: #1f1f1f;
display: none;
}
Menu hamburger is button and i use javascript to open and close it while adding .classList.toggle(class - display: block) on my button
but closing animation doesn't work like i want
i also try to use transform CSS and other things and it doesn't gave me safe effect like i saw at keyframe
I tried to do a class in CSS .opening {anination-name:opening, duration and etc.} and after i tried to add it with javascript (toggle, settimeout adn etc.) nothing is working well for menu closing animation
Thanks
For this, a transition is more suitable:
document.addEventListener('click', () =>
document.querySelector('.menu').classList.toggle('open')
)
.menu {
position: fixed;
height: 100vh;
width: 100vw;
top: 0;
background-color: #1f1f1f;
clip-path: circle(0% at 5% 10%);
transition: clip-path 2s;
}
.menu.open{
clip-path: circle(100%);
}
<div class="menu" ></div>
Click anywhere to try out effect
Just adding basic demo code for your undestanding.
.loader {
width: 56px;
height: 56px;
border: 8px solid transparent;
border-top-color: $warning;
border-bottom-color: $warning;
border-radius: 50%;
animation: loader-rotate 1s linear infinite;
top: 50%;
margin: -28px auto 0;
}
#keyframes loader-rotate {
0% {
transform: rotate(0); }
100% {
transform: rotate(360deg); }
}

Div's border isn't a straight line after rotating in Firefox in Mac

I have a div which has two child div's, one div on the screen plan and other vertically perpendicular to the screen.
I try to rotate the div along Y axis for about 30 degrees. keeping its transform-style 3d preserved.
When doing it, in Firefox the border isn't a straight line anymore. It looks like this
For closer view
I happen to use the following code
.holder {
position: relative;
top: 0;
left: 0;
width: 200px;
height: 226px;
perspective: 2000px;
-moz-perspective: 2000px;
}
.box {
position: absolute;
left: 0;
top: 0;
width: 200px;
height: 226px;
background-color: transparent;
transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform: translateZ( -100px ) rotateY(30deg);
-moz-transform: translateZ( -100px ) rotateY(30deg);
transition: transform 0.5s;
-moz-transition: transform 0.5s;
}
.box div {
position: absolute;
margin: 0;
display: block;
}
.box .front {
left: 0;
right: 0;
top: 0;
bottom: 0;
transform: rotateX(0deg) translateZ(10px);
-moz-transform: rotateX(0deg) translateZ(10px);
background-color: grey;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.box .left {
left: 0;
top: 0;
bottom: 0;
width: 20px;
transform: rotateY(-90deg) translateZ(10px);
-moz-transform: rotateY(-90deg) translateZ(10px);
background-color: black;
background-size: cover;
background-position: left;
background-repeat: no-repeat;
}
<div class="holder">
<div class="box">
<div class="front"></div>
<div class="left"></div>
</div>
</div>
Please let me know if I'm missing anything.
Picture of the link provided in one of the answers :
It's a Firefox aliasing problem, you can add
outline: 1px solid transparent;
as a workaround to .box .front.
I got a work around for your issue reference.
Try filter for the div having class="box".
Basically this is used for svg elements but it is working for your case as well.
filter: url('data:image/svg+xml;utf8,<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><filter id="gaussian_blur"><feGaussianBlur in="SourceGraphic" stdDeviation="0" /></filter></defs></svg>#gaussian_blur');
Tested in latest version of Opera, FF and Chrome for both mac and windows.
Working Demo here
I'm not sure why using translateZ inside a transformed element is not works properly on FF.
Adding outline: 1px solid transparent; is not working, but adding border: 1px solid transparent; to the .box will working, with removing transform: rotateX(0deg) translateZ(10px); from the .box .front.
Example:
.holder {
position: relative;
top: 0;
left: 0;
width: 200px;
height: 226px;
perspective: 2000px;
-moz-perspective: 2000px;
}
.box {
position: absolute;
left: 0;
top: 0;
width: 200px;
height: 226px;
background-color: transparent;
border: 1px solid transparent;
transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
transform: translateZ( -100px ) rotateY(30deg);
-moz-transform: translateZ( -100px ) rotateY(30deg);
transition: transform 0.5s;
-moz-transition: transform 0.5s;
}
.box div {
position: absolute;
margin: 0;
display: block;
}
.box .front {
left: 0;
right: -4px;
top: 0;
bottom: 0;
/* transform: rotateX(0deg) translateZ(10px); */
/* -moz-transform: rotateX(0deg) translateZ(10px); */
background-color: grey;
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.box .left {
left: 0;
top: 0;
bottom: 0;
width: 20px;
transform: rotateY(-90deg) translateZ(10px);
-moz-transform: rotateY(-90deg) translateZ(10px);
background-color: black;
background-size: cover;
background-position: left;
background-repeat: no-repeat;
}
<div class="holder">
<div class="box">
<div class="front"></div>
<div class="left"></div>
</div>
</div>

Can't get div overflow to work properly

I'm hoping someone can help me with an issue I'm running into. I'm trying to set up a series of photos. That have this CSS/HTML property:
http://jsfiddle.net/i_like_robots/7GvV2/embedded/result%2chtml%2ccss/
/*
* Housekeeping
*/
body {
font: normal 16px/1.5 Arial, sans-serif;
}
h1, p {
margin: 0;
padding: 0 0 .5em;
}
.container {
margin: 0 auto;
max-width: 480px;
}
/*
* Caption component
*/
.caption {
position: relative;
overflow: hidden;
/* Only the -webkit- prefix is required these days */
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
.caption::before {
content: ' ';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: transparent;
transition: background .35s ease-out;
}
.caption:hover::before {
background: rgba(0, 0, 0, .5);
}
.caption__media {
display: block;
min-width: 100%;
max-width: 100%;
height: auto;
}
.caption__overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 10px;
color: white;
-webkit-transform: translateY(100%);
transform: translateY(100%);
transition: -webkit-transform .35s ease-out;
transition: transform .35s ease-out;
}
.caption:hover .caption__overlay {
-webkit-transform: translateY(0);
transform: translateY(0);
}
.caption__overlay__title {
-webkit-transform: translateY( -webkit-calc(-100% - 10px) );
transform: translateY( calc(-100% - 10px) );
transition: -webkit-transform .35s ease-out;
transition: transform .35s ease-out;
}
.caption:hover .caption__overlay__title {
-webkit-transform: translateY(0);
transform: translateY(0);
}
I actually got the code from this site.
But there will be upwards of 30 photos, so I was hoping to put them inside a scrolling box/area about 400h x 700w px. When I add the scrolling box, either by HTML, or CSS the results are the same. There is a box, with no scrolling. And all photo's have been shrunken down to fit inside of the box.
Can anyone PLEASE help me with this?
Thanks.
What I've done is removed the CSS for the .container element, in case you want to keep that for a different purpose, and added a .scroller element as a wrapper around the images (within the .container). If you don't have another use for the .container, you can replace .scroller in the CSS with .container, and remove the .container I added to the HTML. A little wordy, so if you need an easier explanation let me know.
So the HTML changes in that there's a new <div> with class scroller surrounding the <article> elements.
The CSS adds the .scroller class, and another rule just to space the images apart a little bit:
.scroller{
margin:0px auto;
height:400px;
max-height:400px;
width:700px;
max-width:700px;
padding:10px 20px;
border:1px solid #aaa;
overflow-y:scroll;
}
.scroller article:not(:last-child){
margin-bottom:10px;
}
Fiddle: http://jsfiddle.net/435rx66s/
What is this scroll box / area?
You've given us this code that you referenced in your implementation, but where is your implementation for us to reference?
The given code works well if you are creating more articles within that container. Give the container a fixed height and set overflow to auto and there should be no problem with getting this content to sit within a scrolling box.
https://jsfiddle.net/i_like_robots/7GvV2/
.container {
height:200px;
overflow:auto;
position:relative;
margin: 0 auto;
max-width: 480px;
}
if you're open to a bit of jquery, there's quite a simple solution.
a short jquery function
$("#container > article:gt(0)").hide();
setInterval(function () {
$('#container > article:first')
.fadeOut(1000)
.next()
.fadeIn(1000)
.end()
.appendTo('#container');
}, 3000);
will show your articles in turn.
$("#container > article:gt(0)").hide();
setInterval(function () {
$('#container > article:first')
.fadeOut(1000)
.next()
.fadeIn(1000)
.end()
.appendTo('#container');
}, 3000);
/*
* Housekeeping
*/
body {
font: normal 16px/1.5 Arial, sans-serif;
}
h1, p {
margin: 0;
padding: 0 0 .5em;
}
#container {
margin:0 auto;
max-width: 480px;
max-height:240px;
overflow:hidden;
}
/*
* Caption component
*/
.caption {
position: relative;
overflow: hidden;
/* Only the -webkit- prefix is required these days */
-webkit-transform: translateZ(0);
transform: translateZ(0);
}
.caption::before {
content: ' ';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: transparent;
transition: background .35s ease-out;
}
.caption:hover::before {
background: rgba(0, 0, 0, .5);
}
.caption__media {
display: block;
min-width: 100%;
max-width: 100%;
height: auto;
}
.caption__overlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 10px;
color: white;
-webkit-transform: translateY(100%);
transform: translateY(100%);
transition: -webkit-transform .35s ease-out;
transition: transform .35s ease-out;
}
.caption:hover .caption__overlay {
-webkit-transform: translateY(0);
transform: translateY(0);
}
.caption__overlay__title {
-webkit-transform: translateY( -webkit-calc(-100% - 10px) );
transform: translateY( calc(-100% - 10px) );
transition: -webkit-transform .35s ease-out;
transition: transform .35s ease-out;
}
.caption:hover .caption__overlay__title {
-webkit-transform: translateY(0);
transform: translateY(0);
}
article{max-width:480px; max-height:240px; overflow:hidden;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div id="container">
<article class="caption">
<img class="caption__media" src="http://farm7.staticflickr.com/6088/6128773012_bd09c0bb4e_z_d.jpg" />
<div class="caption__overlay">
<h1 class="caption__overlay__title">Alaska</h1>
<p class="caption__overlay__content">
Alaska is a U.S. state situated in the northwest extremity of the North American continent. Bordering the state is Canada to the east, the Arctic Ocean to the north, and the Pacific Ocean to the west and south, with Russia (specifically, Siberia) further west across the Bering Strait.
</p>
</div>
</article>
<article class="caption">
<img class="caption__media" src="http://farm7.staticflickr.com/6088/6128773012_bd09c0bb4e_z_d.jpg" />
<div class="caption__overlay">
<h1 class="caption__overlay__title">Michigan</h1>
<p class="caption__overlay__content">
Some dummy text for testing
</p>
</div>
</article>
</div>
</div>

How can I make 2 divs with a slash between

I want make a menu like the image but I don't know how to cut the two divs and make it clickable.
I have tried with svg and borders on divs but I can't get the divs nor svg together because the "outline" still a rectangle!
the image example its on this link:
http://postimg.org/image/ffp6g83fd/537cb837/
I only can make this :
********| *****
******* | ******
****** | *******
***** |********
and I want :
******** *****
******* ******
****** *******
***** ********
and make them clickable
this was my result based on Hugo Marabutt Nogueira answer
http://jsfiddle.net/L7PL4/
Here's one way to do it without too much extra cruft. This uses borders and some css transforms to make the angles.
JSFiddle
CSS
* {
padding: 0;
margin: 0;
}
.container {
width: 100%;
height: 50px;
}
.left,
.right {
float: left;
}
.left span,
.right span {
position: absolute;
line-height: 50px; // equal to height of element
}
.left {
width: 25%; // change as needed
border-bottom: 50px solid blue;
border-right: 50px solid transparent;
-webkit-transform: rotateX(180deg);
}
.left span {
width: 100%;
text-align: center;
-webkit-transform: rotateX(-180deg); // opposite of skew
}
.right {
width: 25%;
border-bottom: 50px solid green;
border-right: 50px solid transparent;
-webkit-transform: rotate(180deg) rotateX(180deg);
}
.right span {
width: 100%;
text-align: center;
-webkit-transform: rotate(-180deg) rotateX(-180deg);
}
Just make sure to unskew the text by using the opposite transforms on them. You'll also have to use all the appropriate vendor prefixing for transforms.
You can use CSS3 Transitions to achieve that shape and then bind a js click to them.
Like this :
http://cdpn.io/stHdg
.skew{
background-color: #333;
width:150px;
height:75px;
float:left;
position:relative;
margin-left:100px;
margin-top:50px;
cursor:pointer;
}
.a:before{
content:"";
position:absolute;
background: #333;
top:0;
left:-25px;
bottom: 0;
width: 50px;
-webkit-transform: skew(-20deg);
-moz-transform: skew(-20deg);
-ms-transform: skew(-20deg);
transform: skew(-20deg);
}
.b:after{
content:"";
position:absolute;
background: #333;
top:0;
right:-25px;
bottom: 0;
width: 50px;
-webkit-transform: skew(-20deg);
-moz-transform: skew(-20deg);
-ms-transform: skew(-20deg);
transform: skew(-20deg);
}
You can use a negative margin to make the element overlap. Example:
margin-right: -5px;

Categories

Resources