Skip to main content

How to create javascript cursor animation and CSS hover effect ?

How to create javascript cursor animation and CSS hover effect ?





SOURCE CODE



HTML SOURCE_CODE:-


<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <title>Page Title</title>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <link rel='stylesheet' type='text/css' media='screen' href='style.css'>
    
</head>
<body>
    <div class="section-fluid-main">
        <div class="section-row">
            <div class="section-col">
                <p><a href="#" class="hover-target img-1">Web design </a>  refers to
 the design of websites that are displayed on the internet.
 It usually refers to the user experience aspects of 
<a href="#" class="hover-target img-2">website development </a> 
than .software development A web designer works on the appearance,
<a href="#" class="hover-target img-3">layout,
 </a>and, in some cases,
 <a href="#" class="hover-target img-4">content of a website</a>.</p>
            </div>
        </div>

        <a href="#" class="hover-target logo" target="_blank">
            <img src="img/img/artspider.jpg" alt="">
        </a>    
    <div class='cursor' id="cursor"></div>
    <div class='cursor2' id="cursor2"></div>
    <div class='cursor3' id="cursor3"></div> 
    </div>
</body>
<script src='index.js'></script>
</html>



CSS SOURCE_CODE:-




/* Please ❤ this if you like it! */


@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700;900&display=swap');
:root {
  --blue#102770;
  --white#ffffff;
  --yellow#ffeba7;
  --purple#9b59b6;
}
*,
*::before,
*::after {
  box-sizingborder-box;
}
::selection {
  colorvar(--yellow);
  background-colorvar(--blue);
}
::-moz-selection {
  colorvar(--yellow);
  background-colorvar(--blue);
}
body{
  background-colorvar(--white);

  background-sizecover;
  background-positioncenter;
  margin0;
  padding0;
  overflow-xhidden;
  min-height100vh;
  display: -ms-flexbox;
  displayflex;
  -ms-flex-wrapwrap;
  flex-wrapwrap;
}
p{
  font-family'Roboto'sans-serif;
  font-weight500;
  font-size26px;
  line-height1.7;
  colorvar(--blue);
  margin0;
}
.section-fluid-main{
  positionrelative;
  displayblock;
  widthcalc(100% - 40px);
  padding-right15px;
  padding-left15px;
  margin-rightauto;
  margin-leftauto;
  max-width1050px;
  padding-top50px;
  padding-bottom90px;
  -ms-flex-item-aligncenter;
  align-selfcenter;
  z-index3;
}
.section-row{
  display: -ms-flexbox;
  displayflex;
  -ms-flex-wrapwrap;
  flex-wrapwrap;
  margin-right-15px;
  margin-left-15px;
  -ms-flex-packcenter;
  justify-contentcenter;
}
.section-col{
  positionrelative;
  width100%;
  -ms-flex0 0 100%;
  flex0 0 100%;
  max-width100%;
  padding15px;
}


/* #Cursor
================================================== */
.cursor,
.cursor2,
.cursor3{
  positionfixed;
  border-radius50%
  transformtranslateX(-50%translateY(-50%);
  pointer-eventsnone;
  left-100px;
  top50%;
  z-index4;
}
.cursor{
  background-colorvar(--blue);
  height0;
  width0;
}
.cursor2,.cursor3{
  height50px;
  width50px;
  transitionall 200ms ease-out;
  background-positioncenter;
  background-size0 0;
}
.cursor2.hover,
.cursor3.hover{
  height220px;
  width320px;
  border:none;
  border-radius8px;
}
.cursor2{
  border2px solid var(--blue);
  box-shadow0 0 12px rgba(16391120.2);
}
.cursor2.hover{
  background-sizecover;
  box-shadow0 0 0 rgba(16391120.2);
}
body.img-1-wrap .cursor2,.cursor3{
  background-imageurl('img/download.jfif');
}
body.img-2-wrap .cursor2,.cursor3{
  background-imageurl('img/download\ \(2\).jfif');
}
body.img-3-wrap .cursor2,.cursor3{
  background-imageurl('img/download\ \(3\).jfif');
}
body.img-4-wrap .cursor2,.cursor3{
  background-imageurl('img/download\ \(1\).jfif');
}
body.logo-wrap .cursor2,.cursor3{
  background-imagenone;
  height50px;
  width50px;
}
body.logo-wrap .cursor2.hover,
body.logo-wrap .cursor3.hover{
  height50px;
  width50px;
  transformscale(2translateX(-25%translateY(-25%);
  border-radius50%;
  background-colorvar(--yellow);
}


.hover-target{
  positionrelative;
  displayinline-block;
  text-decorationnone;
  colorvar(--purple);
  transitioncolor 250ms ease;
}
.hover-target:before{
  positionabsolute;
  content'';
  height0;
  border-radius1px;
  bottom0;
  left-10px;
  widthcalc(100% + 20px);
  border-radius2px;
  displayblock;
  background-colorvar(--yellow);
  transition: height 250ms ease;
  mix-blend-modedifference;
  opacity0.6;
}
.hover-target:hover:before{
  height100%;
}
.hover-target:hover{
  z-index5;
  colorvar(--yellow);
}

.logo {
  positionfixed;
  top25px;
  left25px;
  displayblock;
  
  z-index1000;
}
.logo img {
  height66px;
  widthauto;
  displayblock;
  border-radius50%;
}
.logo:before {
  displaynone;
}

Javascript (.js file) SOURCE_CODE:-

 

/* Please ❤ this if you like it! */

   
document.getElementsByTagName("body")[0].addEventListener("mousemove"function(n) {
    t.style.left = n.clientX + "px"
      t.style.top = n.clientY + "px"
      e.style.left = n.clientX + "px"
      e.style.top = n.clientY + "px"
      i.style.left = n.clientX + "px"
      i.style.top = n.clientY + "px"
  });
  var t = document.getElementById("cursor"),
      e = document.getElementById("cursor2"),
      i = document.getElementById("cursor3");
  function n(t) {
      e.classList.add("hover""hover-2"), i.classList.add("hover""hover-2")
  }
  function s(t) {
      e.classList.remove("hover""hover-2"), i.classList.remove("hover""hover-2")
  }
  s();
  for (var r = document.querySelectorAll(".hover-target, .hover-target-2"), a = r.length - 1a >= 0a--) {
      o(r[a])
  }
  function o(t) {
      t.addEventListener("mouseover"n), t.addEventListener("mouseout"s)
  }
  document.addEventListener('DOMContentLoaded'function () {
      var hoverLink = document.querySelector('.logo');
      var bodychange = document.querySelector('body');

      hoverLink.addEventListener('mouseenter'function (e) {
          bodychange.classList.add('logo-wrap');
      });
      hoverLink.addEventListener('mouseleave'function () {
          bodychange.classList.remove('logo-wrap');
      })
  })
  document.addEventListener('DOMContentLoaded'function () {
      var hoverLink = document.querySelector('.img-1');
      var bodychange = document.querySelector('body');

      hoverLink.addEventListener('mouseenter'function (e) {
          bodychange.classList.add('img-1-wrap');
      });
      hoverLink.addEventListener('mouseleave'function () {
          bodychange.classList.remove('img-1-wrap');
      })
  })
  document.addEventListener('DOMContentLoaded'function () {
      var hoverLink = document.querySelector('.img-2');
      var bodychange = document.querySelector('body');

      hoverLink.addEventListener('mouseenter'function (e) {
          bodychange.classList.add('img-2-wrap');
      });
      hoverLink.addEventListener('mouseleave'function () {
          bodychange.classList.remove('img-2-wrap');
      })
  })
  document.addEventListener('DOMContentLoaded'function () {
      var hoverLink = document.querySelector('.img-3');
      var bodychange = document.querySelector('body');

      hoverLink.addEventListener('mouseenter'function (e) {
          bodychange.classList.add('img-3-wrap');
      });
      hoverLink.addEventListener('mouseleave'function () {
          bodychange.classList.remove('img-3-wrap');
      })
  })
  document.addEventListener('DOMContentLoaded'function () {
      var hoverLink = document.querySelector('.img-4');
      var bodychange = document.querySelector('body');

      hoverLink.addEventListener('mouseenter'function (e) {
          bodychange.classList.add('img-4-wrap');
      });
      hoverLink.addEventListener('mouseleave'function () {
          bodychange.classList.remove('img-4-wrap');
      })
  })


web design video



 

Comments

Popular posts from this blog

How to create Page transition animation by Greensock (gsap)?

 Create Page transition animation by Greensock (gsap) https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/gsap.min.js SOURCE CODE HTML  SOURCE_CODE:- index .html 👇 <! DOCTYPE   html > < html > < head >      < meta   charset = 'utf-8' >      < meta   http-equiv = 'X-UA-Compatible'   content = 'IE=edge' >      < title >  index Page  </ title >      < meta   name = 'viewport'   content = 'width=device-width, initial-scale=1' >      < link   rel = 'stylesheet'   type = 'text/css'   media = 'screen'   href = 'main.css' >      </ head > < body >      < div   class = "header" >          < a   href = "#" >         ...

How To Make A Website Using HTML CSS & JavaScript | Planets Website Design Full Video

artspider designerhttps://www.youtube.com/channel/UCD10SZSEyZCFAR4DFx_uNyg How To Make A Website Using HTML CSS & JavaScript | Planets Website Design Full Video SOURCE CODE HTML  SOURCE_CODE:- index .html 👇 <!DOCTYPE html> <html> <head>     <meta charset='utf-8'>     <meta http-equiv='X-UA-Compatible' content='IE=edge'>     <title>PlanetBook Home Page</title>     <meta name='viewport' content='width=device-width, initial-scale=1'>     <link rel='stylesheet' type='text/css' media='screen' href='style2.css'>      </head> <body>     <div class="header">         <a href="#" class="logo">             <img src="img/planetbooklogo.png" alt="">            </a>            <div class="loc">      ...

Car Website Design Using HTML , CSS and GSAP | Page transition animation by gsap | artspider

               https://cdnjs.cloudflare.com/ajax/libs/gsap/3.5.1/gsap.min.js SOURCE CODE HTML  SOURCE_CODE:- index .html 👇 <! DOCTYPE   html > < html > < head >      < meta   charset = 'utf-8' >      < meta   http-equiv = 'X-UA-Compatible'   content = 'IE=edge' >      < title > page demo </ title >      < meta   name = 'viewport'   content = 'width=device-width, initial-scale=1' >      < link   rel = 'stylesheet'   type = 'text/css'   media = 'screen'   href = 'style2.css' >    </ head > < body >      < div   class = "logo" >< p   id = "logoT" > CARO </ p ></ div >      < div   class = "cover" > < div   class = "maindi...