HOME  >   HTML5 CANVAS  >   CSS3 ANIMATION  >   How to Make HTML5/CSS3 Hyperlink Picture Pop-Up Animation
How to Make HTML5/CSS3 Hyperlink Picture Pop-Up Animation
BY Albert23 Nov,2020
Tags:

Today I will share with you a hyperlink animation based on HTML5 and CSS3. This HTML5 application is quite practical. It allows you to pop up pictures when the mouse moves over the hyperlink, just like a tooltip. Because some CSS3 animation properties are used, there are many kinds of pop-up animations for this hyperlink picture, and you can also try to define some new animation effects yourself.

Advertisement

How to Make HTML5/CSS3 Hyperlink Picture Pop-Up Animation
HTML Body Code
<div class="block" data-fx="1">
			<a class="block__title" data-img="img/1.jpg">Effect 1</a>
			<a class="block__link" data-img="img/2.jpg">chloride</a>
			<a class="block__link" data-img="img/3.jpg">magnesium</a>
			<a class="block__link" data-img="img/4.jpg">zinc</a>
			<a class="block__link" data-img="img/5.jpg">iodine</a>
		</div>
		<div class="block" data-fx="2">
			<a class="block__title" data-img="img/6.jpg">Effect 2</a>
			<a class="block__link" data-img="img/7.jpg">mimas</a>
			<a class="block__link" data-img="img/8.jpg">phobos</a>
			<a class="block__link" data-img="img/9.jpg">lapetus</a>
			<a class="block__link" data-img="img/10.jpg">titania</a>
		</div>
		<div class="block" data-fx="3">
			<a class="block__title" data-img="img/11.jpg">Effect 3</a>
			<a class="block__link" data-img="img/12.jpg">Capitate</a>
			<a class="block__link" data-img="img/13.jpg">Triquetral</a>
			<a class="block__link" data-img="img/14.jpg">scaphoid</a>
			<a class="block__link" data-img="img/15.jpg">Hamate</a>
		</div>
		<div class="block" data-fx="4">
			<a class="block__title" data-img="img/16.jpg">Effect 4</a>
			<a class="block__link" data-img="img/17.jpg">stratus</a>
			<a class="block__link" data-img="img/18.jpg">cirrus</a>
			<a class="block__link" data-img="img/19.jpg">nimbus</a>
			<a class="block__link" data-img="img/20.jpg">cumulus</a>
		</div>                        
Css Code
a {
	text-decoration: none;
	color: var(--color-link);
	outline: none;
}

a:hover,
a:focus {
	color: var(--color-link-hover);
}

button:focus,
a:focus {
	outline: none;
}

main {
	position: relative;
	width: 100%;
}

.block {
	text-transform: lowercase;
	padding: 0 5vw 20vh;
	display: flex;
	flex-direction: column;
	align-items: center;
}

.block__title {
	position: relative;
	font-size: 1rem;
	margin: 0 0 1.5rem 0;
	padding: 0.5rem 0;
	cursor: pointer;
	font-weight: bold;
	color: var(--color-blocktitle);
}                        
Js Code
const getMousePos = (e) => {
        let posx = 0;
        let posy = 0;
		if (!e) e = window.event;
		if (e.pageX || e.pageY) {
            posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY) 	{
			posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
		}
        return { x : posx, y : posy }
    }
    const getRandomFloat = (min, max) => (Math.random() * (max - min) + min).toFixed(2);                        

Advertisement