Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="productBox">
	<div class="product">
		<a class="productImage" href=",0.5,0,0&iccEmbed=0&layer=comp&.v=1474481298618">
			<div class="magnifier"></div>
			<img src=",0.5,0,0&iccEmbed=0&layer=comp&.v=1474481298618" alt="Product Image">
	<div class="featureImages">
		<a href=""><img src=""></a>
<div class="zoomImage"></div>


                .productImage {
	position: relative;
	float: left;

.product {
	height: 300px;
	overflow: hidden;

.product img {
	height: 100%;

.productBox, .product {
	float: left;

.magnifier {
	position: absolute;
	opacity: 0; 
	background: rgba(255,255,255,0.5); 

.magnifierChoose {
	float: left;

.zoomImage {
	float: left;
	width: 200px;
	height: 200px;
	position: relative;
	overflow: hidden;
	margin-left: 100px; 

.zoomImage img {
	position: absolute;
	transform: scale(2); 
	top: 0;
	left: 0;

.featureImages {
	width: 100%;
	float: left;
	height: 100px;

.featureImages img {
	height: 100%;


                // define variables
var theImage = document.querySelector('.product'); // image css class
var magnifier = document.querySelector('.magnifier'); // magnifier css class
var zoomImage = document.querySelector('.zoomImage'); // zoom image container
var featureImages = document.querySelector('.featureImages'); // define feature images
var magnifierHeight = 100; // define height of magnifier in px
var magnifierWidth = 100; // define width of magnifier in px

// set width and height = magnifierHeight+"px"; = magnifierWidth+"px"; 

var img = new Image(); 
img.src = theImage.querySelector('img').getAttribute('src'); 

// add onmousemove event
theImage.addEventListener('mouseenter', function(){
	this.addEventListener('mousemove', function(e){



function generateZoom()
	theImage.addEventListener('mousemove', function(event){

		// center the magnifier to cursor
		var posX = event.clientX-magnifierWidth/2+"px"; 
		var posY = event.clientY-magnifierHeight/2+"px"; = 1; = posX; = posY; 

		var imageWidth = parseInt(getComputedStyle(this.querySelector('img')).width);
		var imageHeight = parseInt(getComputedStyle(this.querySelector('img')).height);

		var magnifierPercentX = magnifierWidth/imageWidth*100; 
		var magnifierPercentY = magnifierHeight/imageHeight*100; 

		var zoomX = event.clientX/imageWidth*100;
		var zoomY = event.clientY/imageHeight*100;

		zoomImage.querySelector('img').style.transform = "translateX("+-zoomX+"%) translateY("+-zoomY+"%)";
		// zoomImage.querySelector('img').style.left = magnifierPercentX*2+"%"; 
		// zoomImage.querySelector('img') = magnifierPercentY*2+"%";  

function removeZoom()
{ = 0; 

theImage.addEventListener('mouseenter', generateZoom); 
theImage.addEventListener('mouseleave', function(e){
	this.removeEventListener('mousemove', generateZoom)

var addingImageContainer = document.createElement('a'); 
addingImageContainer.href = theImage.querySelector('img').getAttribute('src');
var addingImage = new Image(); 
addingImage.src = theImage.querySelector('img').getAttribute('src');

var featureImagesArray = featureImages.querySelectorAll('a');

for (var i = 0; i < featureImagesArray.length; i++) {
	featureImagesArray[i].addEventListener('click', function(e){

		var imgLink = this.getAttribute('href'); 
		theImage.querySelector('img').setAttribute('src', imgLink);
		img.src = imgLink;