Perspective Origin Demo
How do I make an perspective origin demo?
This is used to embed in my blog http://agelber.com/blog/3d-transforms. What is a perspective origin demo? How do you make a perspective origin demo? This script and codes were developed by Assaf Gelber on 03 January 2023, Tuesday.
Perspective Origin Demo - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Perspective Origin Demo</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ @import 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300';
body { overflow: hidden; font-family: Source Sans Pro; perspective: 400px; transform: translateZ(0);
}
#element { box-sizing: border-box; position: absolute; left: 250px; width: 100px; height: 100px; background: #387FF2; border: 3px solid #444; margin: 50px auto; transition: transform 0.25s;
}
#element:hover { transform: rotateX(45deg) rotateY(45deg);
}
.explanation { font-weight: bold; width: 200px;
}
.slider, #css { position: relative;
}
.slider label, #css label { display: inline-block; width: 12px;
}
.slider input, #css input { vertical-align: middle;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div id='element'></div>
<div class='explanation'> When hovered over, the square will be rotated 45 degrees around the X and Y axes. Change the origin to see the affect.
</div>
<div class='slider'> <label>X:</label> <input id='xslider' max='100' min='0' type='range'>
</div>
<div class='slider'> <label>Y:</label> <input id='yslider' max='100' min='0' type='range'>
</div>
<div id='css'>perspective-origin: 50% 50%</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Perspective Origin Demo - Script Codes CSS Codes
@import 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300';
body { overflow: hidden; font-family: Source Sans Pro; perspective: 400px; transform: translateZ(0);
}
#element { box-sizing: border-box; position: absolute; left: 250px; width: 100px; height: 100px; background: #387FF2; border: 3px solid #444; margin: 50px auto; transition: transform 0.25s;
}
#element:hover { transform: rotateX(45deg) rotateY(45deg);
}
.explanation { font-weight: bold; width: 200px;
}
.slider, #css { position: relative;
}
.slider label, #css label { display: inline-block; width: 12px;
}
.slider input, #css input { vertical-align: middle;
}
Perspective Origin Demo - Script Codes JS Codes
var el = document.body, css = document.getElementById('css'), x = 50, y = 50;
document.getElementById('xslider').addEventListener('change', function() { x = this.value; update();
}, false);
document.getElementById('yslider').addEventListener('change', function() { y = this.value; update()
}, false);
function update() { var prop = x + '% ' + y + '%'; el.style[Modernizr.prefixed('perspectiveOrigin')] = prop; css.innerText = 'perspective-origin: ' + prop;
}
Developer | Assaf Gelber |
Username | agelber |
Uploaded | January 03, 2023 |
Rating | 3 |
Size | 3,614 Kb |
Views | 16,192 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Animation Demo | 3,031 Kb |
Text Looping Transition | 5,619 Kb |
Skew Demo | 3,209 Kb |
Rotate Demo | 3,061 Kb |
CSS Only Single-Element 3D Cuboid | 2,913 Kb |
Posting Animation | 4,524 Kb |
Social Link Handle Animation | 3,241 Kb |
Simple Night Sky | 3,266 Kb |
Origin Demo | 3,523 Kb |
Translate Demo | 3,188 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Hello People | Danburrows | 2,365 Kb |
CSS Google Now | Jackmoran | 3,196 Kb |
Custom Checkbox and radio inputs SCSS | Rgfx | 3,367 Kb |
Filtering with shuffle.js | Deyand | 2,712 Kb |
A Pen by Alex Bergin | Abergin | 3,347 Kb |
How to add Css Fold Notes In Blogger By Askwithloud.com | Askwithloud | 2,280 Kb |
CSS Dynamic Width Square Div | Elleestcrimi | 2,861 Kb |
Button fills | Zubfatal | 5,205 Kb |
Testimonial Fancy tabs responsive | Amit-webdesigner | 3,056 Kb |
Pruebas de d3.js | Juanmanuelcarnerero | 2,485 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!