JavaScript

How to Use jquery.imagecube.js to Combine Multiple Images and Display Them Rotating Like a Cube

This article provides a detailed explanation of how to use jquery.imagecube.js to display multiple images rotating like a cube. Please give it a try.

First, we will prepare the necessary files and code to create a demo that rotates images like a cube using jQuery and jquery.imagecube.js. In this sample, we will use six images to display on each face of the cube.

Preparing the Necessary Files

Please prepare the following files.

  • jquery.min.js (minified version of jQuery)
  • jquery.imagecube.js (plugin for achieving cube rotation display)
  • jquery.easing.1.3.js (plugin supporting animation easing)

 
These files can be downloaded from the internet.

CSS Settings

First, set the CSS for the rotation display area (#idCube) and the images. Use the code below and modify it as needed.

<style type="text/css">
<!--
body{
	margin:0;
	padding:0;
}
h1{
	font-size:16px;
	font-weight:normal;
	line-height:1.6em;
	text-align:center;
	padding:15px 0;
}
#idWrap{
	width:700px;
	margin:0 auto;
	text-align:center;
}
#idCube{ 
  width:300px;
  height:300px;
  margin:0 auto;
}
a img{
	border: none;
}
#linksCube img{
	width: 100%;
	height: 100%;
}
-->
</style>

HTML Settings

Next, set up the HTML file. We have prepared an area (id=”idCube”) and six images to display rotating like a cube. Please refer to the code below.

<div id="idWrap">
	<h1>Display multiple single images rotating like a cube</h1>

    <div id="idCube">
    <img src="images/i1.jpg" width="300" alt="" />
    <img src="images/i2.jpg" width="300" alt="" />
    <img src="images/i3.jpg" width="300" alt="" />
    <img src="images/i4.jpg" width="300" alt="" />
    <img src="images/i5.jpg" width="300" alt="" />
    <img src="images/i6.jpg" width="300" alt="" />
    </div><!--/idCube-->


</div><!--/idWrap-->

JavaScript Settings

Finally, set up JavaScript.
Load the jquery.min.js, jquery.imagecube.js, and jquery.easing.1.3.js files. Use $(“rotation display area”).imagecube({options}) to set options such as rotation direction for the rotation display area.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> 
<script type="text/javascript" src="jquery.imagecube.js"></script>
<script type="text/javascript" src="jquery.easing.1.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$("#idCube").imagecube({randomSelection:['up', 'down', 'left', 'right']});
});
</script>

jquery.imagecube: Demo Page for Displaying Multiple Images Rotating Like a Cube

jquery.imagecube: Demo Page for Displaying Multiple Images Rotating Like a Cube

Source: jQuery Image Cube

jQuery Image Cube

Conclusion

This concludes the explanation of how to display multiple images rotating like a cube using jquery.imagecube.js. This technique allows you to add dynamic and visually appealing content to your web pages. It’s easy to implement, so please give it a try.
I hope this article is helpful in your development.

 
*Please use this at your own risk if you decide to repurpose it.
Do not reuse the Google Analytics tag inside the demo page tag.