Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <div class="flex">
	<div class="hover truck">
		<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" preserveAspectRatio="xMidYMid meet">
			<g id="truck">
				<rect class="stroke stroke-black fill-white" x="120.78" y="60.43" width="10.44" height="2.1" />
				<rect class="stroke stroke-black fill-white" x="75.43" y="56.28" width="101.15" height="111.54" />
				<rect class="stroke stroke-black fill-white" x="87.97" y="167.83" width="75.54" height="18.08" />
				<rect class="stroke stroke-black fill-white" x="75.43" y="185.91" width="101.15" height="4.33" />
				<rect class="stroke stroke-black fill-white" x="78" y="167.83" width="3.75" height="18.08" />
				<rect class="stroke stroke-black fill-white" x="170.25" y="167.83" width="3.75" height="18.08" />
				<rect class="stroke stroke-black fill-white" x="109.7" y="167.83" width="32.6" height="6.54" />
				<path class="stroke stroke-black fill-none" d="M90.64,190.23h21.78a0,0,0,0,1,0,0v3.07a2.41,2.41,0,0,1-2.41,2.41H93.06a2.41,2.41,0,0,1-2.41-2.41v-3.07A0,0,0,0,1,90.64,190.23Z" />
				<path class="stroke stroke-black fill-none" d="M139.56,190.23h21.78a0,0,0,0,1,0,0v3.38a2.1,2.1,0,0,1-2.1,2.1H141.66a2.1,2.1,0,0,1-2.1-2.1v-3.38A0,0,0,0,1,139.56,190.23Z" />
				<line class="stroke stroke-black fill-none" x1="113.4" y1="185.57" x2="113.4" y2="174.5" />
				<line class="stroke stroke-black fill-none" x1="137.69" y1="185.57" x2="137.69" y2="174.5" />
				<line class="stroke stroke-black fill-none" x1="113.62" y1="181.62" x2="137.56" y2="181.62" />
				<rect class="stroke stroke-black fill-white" x="84.56" y="167.99" width="6.75" height="7.71" />
				<rect class="stroke stroke-black fill-white" x="160.04" y="167.99" width="6.75" height="7.71" />
			</g>

			<g id="inside">
				<rect class="stroke stroke-black fill-white" x="80.66" y="62.06" width="90.68" height="100" />
				<polygon class="stroke stroke-black fill-white" points="160.69 161.97 91.31 161.74 91.31 85.35 160.69 85.35 160.69 161.97" />
				<line class="stroke stroke-black fill-none" x1="80.66" y1="62.06" x2="91.31" y2="85.35" />
				<line class="stroke stroke-black fill-none" x1="114" y1="85.35" x2="114" y2="160.67" />
				<line class="stroke stroke-black fill-none" x1="137.47" y1="85.35" x2="137.47" y2="160.67" />
				<line class="stroke stroke-black fill-none" x1="160.69" y1="85.35" x2="171.34" y2="62.06" />
			</g>
			
			<!-- Door Left -->
			<foreignobject width="100%" height="100%">
				<div xmlns="http://www.w3.org/1999/xhtml" id="door-left"> 
					<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" preserveAspectRatio="xMidYMid meet">
						<defs>
							<clipPath id="truck-clip">
								<rect id="door-left" class="stroke stroke-black fill-white" x="80.66" y="62.06" width="45.34" height="100" />
							</clipPath> 
						</defs>

						<g >
							<rect class="fill-white" x="80.66" y="62.06" width="45.34" height="100" />
							<g style="clip-path: url(#truck-clip)">
								<line class="stroke stroke-black fill-none" x1="120" y1="62.53" x2="120" y2="161.58" />
								<rect class="fill-black" x="109.93" y="144.8" width="10.07" height="2.53" transform="translate(229.93 292.12) rotate(-180)" />
								<rect class="stroke stroke-black fill-none" x="118.25" y="62.53" width="3.49" height="3.49" transform="translate(240 128.55) rotate(-180)" />
								<rect class="fill-black" x="84.4" y="151.21" width="11.34" height="3.14" />
							</g>
							<rect class="stroke stroke-black fill-none" x="80.66" y="62.06" width="45.34" height="100" />
						</g>
					</svg>
				</div>
			</foreignobject>

			<!-- Door Right -->
			<foreignobject width="100%" height="100%">
				<div xmlns="http://www.w3.org/1999/xhtml" id="door-right">
					<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" preserveAspectRatio="xMidYMid meet">
						<defs>
							<clipPath id="truck-clip1">
								<rect class="stroke stroke-black fill-white" x="126" y="62.06" width="45.34" height="100" />
							</clipPath>
						</defs>

						<g id="door-right">
							<rect class="fill-white" x="126" y="62.06" width="45.34" height="100" />
							<g style="clip-path: url(#truck-clip1)">
								<line class="stroke stroke-black fill-none" x1="132" y1="62.53" x2="132" y2="161.58" />
								<rect class="fill-black" x="132" y="144.8" width="10.07" height="2.53" />
								<rect class="stroke stroke-black fill-none" x="130.25" y="62.53" width="3.49" height="3.49" />
							</g>
							<rect class="stroke stroke-black fill-none" x="126" y="62.06" width="45.34" height="100" />
						</g>
					</svg>
				</div>
			</foreignobject>
			
			<g id="cart" class="truck-cart">
			<polyline class="stroke stroke-black fill-white" points="64.85 183.66 64.85 191.27 42.34 191.27 42.34 183.66" />
			<rect class="stroke stroke-black fill-white" x="25.11" y="164.6" width="19.05" height="19.05" />
			<rect class="stroke stroke-black fill-white" x="44.16" y="164.6" width="19.05" height="19.05" />
			<rect class="stroke stroke-black fill-white" x="63.2" y="164.6" width="19.05" height="19.05" />
			<rect class="stroke stroke-black fill-white" x="25.11" y="145.55" width="19.05" height="19.05" />
			<rect class="stroke stroke-black fill-white" x="44.16" y="145.55" width="19.05" height="19.05" />
			<rect class="stroke stroke-black fill-white" x="63.2" y="145.55" width="19.05" height="19.05" />
			<rect class="stroke stroke-black fill-white" x="63.2" y="126.51" width="19.05" height="19.05" />
			<rect class="stroke stroke-black fill-white" x="25.11" y="126.51" width="38.09" height="6.35" />
			<rect class="stroke stroke-black fill-white" x="25.11" y="132.86" width="38.09" height="6.35" />
			<rect class="stroke stroke-black fill-white" x="25.11" y="139.2" width="38.09" height="6.35" />
			<rect class="stroke stroke-black fill-white" x="70.47" y="126.51" width="4.07" height="57.14" />
			<rect class="fill-black" x="24" y="124.09" width="59.59" height="2.42" />
			<rect class="fill-black" x="40.75" y="128.76" width="6.81" height="1.59" />
			<rect class="fill-black" x="40.75" y="135.23" width="6.81" height="1.59" />
			<rect class="fill-black" x="40.75" y="141.58" width="6.81" height="1.59" />
			<rect class="fill-black" x="31.55" y="148.14" width="5.4" height="2.03" />
			<rect class="fill-black" x="50.39" y="148.14" width="5.4" height="2.03" />
			<rect class="fill-black" x="31.55" y="167.68" width="5.4" height="2.03" />
			<rect class="fill-black" x="50.39" y="167.68" width="5.4" height="2.03" />
			<rect class="fill-black" x="51.07" y="186.35" width="5.01" height="1.89" />
			<circle class="stroke stroke-black fill-white" cx="31.98" cy="191.04" r="4.68" />
			<path class="stroke stroke-black fill-white" d="M27.3,183.87l3.27,7.72s.57,2,2.21.41a1.44,1.44,0,0,0,0-1.89L30,183.87Z" />
			<circle class="stroke stroke-black fill-white" cx="76.83" cy="190.98" r="4.68" />
			<path class="stroke stroke-black fill-white" d="M72.15,183.81l3.27,7.72s.57,2,2.21.41a1.44,1.44,0,0,0,0-1.89l-2.74-6.24Z" />
		</g>
			
			<g id="boxes">
			<g class="truck-box-top">
				<path class="stroke stroke-black fill-white" d="M228,135.48v28a2,2,0,0,1-2,2H184.52a2,2,0,0,1-2.05-2v-28Z" />
				<line class="stroke stroke-black fill-none" x1="182.52" y1="149.21" x2="227.83" y2="149.21" />
				<rect class="stroke stroke-black fill-white" x="191.73" y="145.07" width="4.23" height="8.2" />
				<rect class="stroke stroke-black fill-white" x="214.05" y="145.07" width="4.23" height="8.2" />
			</g>
			<g class="truck-box-bottom">
				<path class="stroke stroke-black fill-white" d="M224.8,165.72v27.95a2,2,0,0,1-2,2.05H181.32a2,2,0,0,1-2-2.05V165.72Z" />
				<line class="stroke stroke-black fill-none" x1="179.32" y1="179.46" x2="224.63" y2="179.46" />
				<rect class="stroke stroke-black fill-white" x="188.53" y="175.32" width="4.23" height="8.2" />
				<rect class="stroke stroke-black fill-white" x="210.85" y="175.32" width="4.23" height="8.2" />
			</g>
		</g>
		</svg>
	</div>
</div>
              
            
!

CSS

              
                .flex { 
	display: flex;
	justify-content: center;
	align-items: center;
}

.truck {
	width: 25%;
}

.stroke {
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 2px;
}

.stroke-dash1 	{ stroke-dasharray: 20 10 20; }
.stroke-dash2 	{ stroke-dasharray: 24 16 8; }

.stroke-black 	{ stroke: #38383A; }
.stroke-red 		{ stroke: #DD2828; }

.fill-none 			{ fill: none; }
.fill-white 		{ fill: #FFFFFF; }
.fill-black			{ fill: #38383A; }
.fill-red 			{ fill: #DD2828; }

.hidden 				{ visibility: hidden; }
              
            
!

JS

              
                TweenLite.defaultEase = Expo.easeOut;

// Truck
function truck() {
	var truckAnim = new TimelineMax();
	truckAnim.to("#door-left", 1, { rotationY: 140, skewY: 5, transformOrigin:"80.661px 112.057px", transformStyle: "preserve-3d", perspective:800 }, "truck")
		.to("#door-right", 1, { rotationY: -140, skewY: -5, transformOrigin:"171.339px 112.057px", transformStyle: "preserve-3d", perspective:800 }, "truck")
		.from(".truck-cart", 1, { autoAlpha: 0, x: -20, }, "truck+=0.25")
		.from(".truck-box-top", .5, { autoAlpha: 0, x: 10, }, "truck+=0.40")
		.from(".truck-box-bottom", .5, { autoAlpha: 0, x: 10, }, "truck+=0.30");
	return truckAnim;
};

// Creat Timlines
var tlTruck = new TimelineMax();

// Add animation to timelines
tlTruck.add(truck());

//Pause timelines on page load
tlTruck.pause();


// On hover play animations
$(".hover").mouseenter( function() {
	if($(this).hasClass('truck')) {
		tlTruck.play();
	};
});

// On leave reverse or other functions
$(".hover").mouseleave( function() {
	if($(this).hasClass('truck')){
		tlTruck.reverse();
	};
});
              
            
!
999px

Console