Jump to content

Que594

Member
  • Posts

    46
  • Joined

  • Last visited

Community Answers

  1. Que594's post in Parallax Mouse on Images was marked as the answer   
    @pedin36460 I found a bit of code that you should be able to mess around with. Paste it all in a code block.
    This ended up working for my site 🙂 Good luck!
     
     
    <!DOCTYPE html>
    <html lang="en">
      <head>
        <style>
          * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: sans-serif;
          }
          body {
            background-color: rgb(102, 189, 16);
          }
          .mouse_move {
            position: relative;
            width: 100%;
            height: 100vh;
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
          }
          .mouse_move h2 {
            position: relative;
            font-size: 100px;
            color: white;
          }
          .mouse_move img {
            position: absolute;
          }
          #img1 {
            top: 80px;
            left: 80px;
            height: 250px;
            width: 250px;
          }
          #img2 {
            bottom: 80px;
            right: 80px;
            height: 250px;
            width: 250px;
          }
        </style>
        <title>Parallax</title>
      </head>
      <body>
        <div class="mouse_move">
          <img
            id="img1"
            src=
    "https://media.geeksforgeeks.org/wp-content/uploads/20210101144014/gfglogo.png"
            class="mouse"
            value="5"/>
          <h2>GeeksforGeeks</h2>
          <img
            id="img2"
            src=
    "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"
            class="mouse"
            value="-5"/>
        </div>
        <script type="text/javascript">
          document.addEventListener("mousemove", parallax);
          function parallax(event) {
            this.querySelectorAll(".mouse").forEach((shift) => {
              const position = shift.getAttribute("value");
              const x = (window.innerWidth - event.pageX * position) / 90;
              const y = (window.innerHeight - event.pageY * position) / 90;
              shift.style.transform = `translateX(${x}px) translateY(${y}px)`;
            });
          }
        </script>
      </body>
    </html>
  2. Que594's post in Is this navbar possible with coding? was marked as the answer   
    Below is the code I used for this (kind of messy, not a pro coder. lol). It woooorks!
     
    //* determines height of site logo *//
     #header {
       margin: -120px auto;
       padding: 0px 0px;
    }
    //* pushing site logo to left of nav *//
    #header #logoWrapper, 
    #header #siteTitleWrapper { 
       position: relative; 
       left: 15%; 
       -webkit-transform: translate(-50%,0); 
       -moz-transform: translate(-50%,0); 
       -ms-transform: translate(-50%,0); 
       -o-transform: translate(-50%,0); 
       transform: translate(-90%,80%); 
       text-align: right !important;
    }
    #header #mainNavWrapper .index { 
       margin: 0 0 0 12px !important; 
       text-align: right !important;
    }
    //* removes center gap from logo *//
    #mainNavigation div.collection {
       margin: 0 !important;
    }
    #header #mainNavWrapper {
       text-align: right !important;
    }
    //* positioning of nav links *//
    #header #mainNavWrapper {
       text-align: right !important;
       right: 12%;
    }
×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.