html
html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html>
<head>
<title>Floated Buttons</title>
</head>
<body>
<!-- Header Title -->
<h1 class="hero-header">In The Name Of GOD</h1>
<!-- /Header Title -->
<!-- Sub Header Title -->
<p class="hero-sub-title">We have come to serve you</p>
<!-- /Sub Header Title -->
<!-- Container -->
<div class="hero-btn-container">
<!-- Button1 -->
<div class="hero-btn-wrapper1">
<a href="#" class="hero-btn">
<img class="hero-btn-support" src="https://img.icons8.com/instagram" />
<span>Support</span>
</a>
</div>
<!-- /Button1 -->
<!-- Button2 -->
<div class="hero-btn-wrapper2">
<a href="#" class="hero-btn">
<img class="hero-btn-education" src="https://img.icons8.com/education" />
<span>Education</span>
</a>
Enter to Rename, Shift+Enter to Preview
css
css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
* {
margin: 0;
padding: 0;
box-sizing: border-box;
direction: rtl;
}
body{
overflow-x: hidden;
}
/*******************************************************************************************/
/* Main Styles */
/* #########Header########### */
.hero-header{
font-size: 50px;
text-align: center;
margin: 50px auto;
}
/* #########Subtitle########### */
.hero-sub-title{
font-size: 20px;
text-align: center;
margin: 0px auto 50px;
}
Enter to Rename, Shift+Enter to Preview
js
js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const heroSubHeader = document.querySelector('.hero-sub-title');
const moveBtn = (e) => {
const btnHero1 = document.querySelector('.hero-btn-wrapper1 a');
const btnHero2 = document.querySelector('.hero-btn-wrapper2 a');
if(e[0].isIntersecting){
btnHero1.classList.remove('floating');
btnHero2.classList.remove('floating');
}
if(!e[0].isIntersecting){
btnHero1.classList.add('floating');
btnHero2.classList.add('floating');
}
}
const btnIntersectionObs= new IntersectionObserver(moveBtn);
btnIntersectionObs.observe(heroSubHeader);
Enter to Rename, Shift+Enter to Preview
BROWSER
Console
Run