MalikDzgn
  • Jelajahi

    Copyright © MalikDzgn -

    Quickly update interesting info starting today

    Malikdzgn

    Malikdzgn

    Software

    [Umum][recentbylabel]

    mercredi 24 février 2021

    Dynamically Scale Elements Relative To Its Container – Scalable

    Dynamically Scale Elements Relative To Its Container – Scalable

     

    Dynamically Scale Elements Relative To Its Container – Scalable

    Category: Javascript , Recommended | August 14, 2017
    AUTHOR:ScriptArtist
    VIEWS TOTAL:290 views
    OFFICIAL PAGE:Go to website
    LAST UPDATE:August 14, 2017
    LICENSE:MIT

    Preview:

    Dynamically Scale Elements Relative To Its Container – Scalable

    Description:

    Scalable is a simple, lightweight JavaScript element resizing library which dynamically resizes any element while keeping the original aspect ratio and alignment inside its parent container.

    Install the scalable with NPM:

    $ npm install scalable

    How to use it:

    Import the Scalable JavaScript into the document.

    <script src="build/scalable.js"></script>

    Let’s say you have an element inside the ‘container’ element as this:

    <div class="container">
      <div class="myElement">
        Resizable element here
      </div>
    </div>

    Create a new scalable object and specify the container element.

    var scalable = new Scalable(".container", {
        // options here
    });

    That’s it. All possible options to customize the Scalable.

    var scalable = new Scalable(".container", {
    
        // left | center | right 
        align: left,
    
        // top | center | bottom
        verticalAlign: top,
    
        // fixed | auto
        containerHeight: fixed,
        
        // minimum width
        minWidth: null,
    
        // maximum width
        maxWidth: null,
    
        // minimux scale
        minScale: null,
    
        // maximum scale
        maxScale: null
    
    });
    Responsive Hamburger Sidebar Navigation In Pure JavaScript – Omega.js

    Responsive Hamburger Sidebar Navigation In Pure JavaScript – Omega.js

     

    Responsive Hamburger Sidebar Navigation In Pure JavaScript – Omega.js

    Category: Javascript , Menu & Navigation | April 5, 2019
    AUTHOR:SelMaK-fr
    VIEWS TOTAL:2,885 views
    OFFICIAL PAGE:Go to website
    LAST UPDATE:April 5, 2019
    LICENSE:MIT

    Preview:

    Responsive Hamburger Sidebar Navigation In Pure JavaScript – Omega.js

    Description:

    Omega.js is a modern responsive mobile-first navigation system for the web.

    It uses CSS media queries to detect the screen size and collapse the regular navbar into a hamburger sidebar navigation (aka. off-canvas navigation).

    Click/tap the hamburger button to toggle the sidebar navigation sliding out from the edge of the screen.

    See also:

    How to use it:

    Import the Omega’s JavaScript and CSS files into the document.

    <link rel="stylesheet" href="assets/css/omega.css">
    <script src="assets/js/omega.js"></script>

    Create the HTML for the sidebar navigation and done.

    <div id="omega">
      <div id="omega-content">
        <nav>
          <ul>
            <li><a href="#">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Blog</a></li>
            <li><a href="#">Contact</a></li>
          </ul>
        </nav>
        <div class="omega-links">
          <a href="#" class="button">Link 1</a>
          <a href="#" class="button button-outline ">Link 2</a>
        </div>
    
      </div>
      <button id="omega-button">&#9776;</button>
      <div id="omega-sidebar">
        <div id="omega-sidebar-header"></div>
        <div id="omega-sidebar-body"></div>
      </div>
      <div id="omega-overlay"></div>
    </div>
    Mobile-first Site Navbar With JavaScript & CSS

    Mobile-first Site Navbar With JavaScript & CSS

     

    Mobile-first Site Navbar With JavaScript & CSS

    Category: Javascript , Menu & Navigation | October 29, 2020
    AUTHOR:amateur-bot
    VIEWS TOTAL:946 views
    OFFICIAL PAGE:Go to website
    LAST UPDATE:October 29, 2020
    LICENSE:MIT

    Preview:

    Mobile-first Site Navbar With JavaScript & CSS

    Description:

    A modern, responsive, mobile-first site navigation that collapses nav items into a sidebar off-canvas menu on mobile.

    How to use it:

    1. Create a navbar from a nav list as follows:

    <nav class="navbar">
      <h1 class="navbar-brand">
        Navbar Here
      </h1>
      <ul class="nav-list">
        <li class="nav-item">
          <a class="nav-link active" href="#">
            home
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">
            JavaScript
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">
            CSS
          </a>
        </li>
      </ul>
    </nav>

    2. Insert a hamburger toggle button into the navbar.

    <div class="menu-toggle">
      <div class="hamburger">
      </div>
    </div>

    3. The core CSS styles for the sidebar off-canvas menu and menu toggler.

    .navbar {
      display: flex;
      justify-content: space-between;
      align-items: center;
      height: 8rem;
    }
    
    .navbar-brand {
      color: #ffffff;
      font-family: "Oswald", sans-serif;
      text-transform: uppercase;
    }
    
    .nav-list {
      list-style: none;
      position: fixed;
      top: 0;
      left: 0;
      width: 80%;
      height: 100vh;
      background-color: #222222;
      padding: 4.4rem;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      z-index: 1250;
      text-transform: uppercase;
      transform: translateX(-100%);
      transition: transform 0.5s;
    }
    
    .nav-link:hover {
      border-bottom: 3px solid #ffffff;
    }
    
    .active {
      font-weight: 700;
      border-bottom: 3px solid #ffffff;
    }
    
    .open .nav-list {
      transform: translateX(0);
    }
    
    .menu-toggle {
      position: relative;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 3.2rem;
      height: 3.2rem;
      cursor: pointer;
      transition: all 0.5s ease-in-out;
    }
    
    .hamburger {
      width: 2.4rem;
      height: 3px;
      background-color: #ffffff;
      border-radius: 2px;
      border: none;
      transition: all 0.7s ease-out;
    }
    
    .hamburger::before,
    .hamburger::after {
      content: "";
      position: absolute;
      width: 2.4rem;
      height: 3px;
      background-color: #ffffff;
      border-radius: 2px;
      border: none;
    }
    
    .hamburger::before {
      transform: translateY(-8px);
    }
    
    .hamburger::after {
      transform: translateY(8px);
    }

    4. Setup menu toggle animations in the CSS.

    .open .hamburger {
      background: transparent;
    }
    
    .open .hamburger::before {
      transform-origin: (0, 0);
      transform: rotate(45deg);
    }
    
    .open .hamburger::after {
      transform-origin: (0, 0);
      transform: rotate(-45deg);
    }

    5. Apply the following CSS styles to the navbar when running on tablet or desktop.

    @media screen and (min-width: 768px) {
      .nav-list {
        position: initial;
        width: initial;
        height: initial;
        background-color: transparent;
        padding: 0;
        justify-content: initial;
        flex-direction: row;
        transform: initial;
        transition: initial;
      }
      .nav-link {
        margin-left: 4rem;
        font-size: 1.6rem;
        transition: all 0.1s;
      }
      .menu-toggle {
        display: none;
      }
    }

    6. The JavaScript to enable the hamburger menu toggler.

    const navbar = document.querySelector(".navbar");
    const menuToggle = document.querySelector(".menu-toggle");
    menuToggle.addEventListener("click", () => {
      navbar.classList.toggle("open");
    });
       CSS Only Responsive Sticky Navbar

    CSS Only Responsive Sticky Navbar

     

    CSS Only Responsive Sticky Navbar

    Category: CSS & CSS3 , Menu & Navigation , Recommended | June 25, 2020
    AUTHOR:sam-cross
    VIEWS TOTAL:2,579 views
    OFFICIAL PAGE:Go to website
    LAST UPDATE:June 25, 2020
    LICENSE:MIT

    Preview:

    CSS Only Responsive Sticky Navbar

    Description:

    responsive sticky navbar that coverts the nav items into a full-width off-canvas menu with a hamburger toggle button.

    Clicking/tapping the hamburger will slide the off-canvas menu out from the left side of the screen.

    Written in pure HTML and CSS/CSS3. Fully customizable by overriding the default variables in the main.scss.

    How to use it:

    1. Modify the CSS variables (colors, transitions, breakpoints) to fit your design.

    // main.scss
    $breakpoint_tablet: 680px;
    $breakpoint_desktop: 1040px;
    $max_header_width: 1200px;
    $color_background: #FAFAFA;
    $color_background_alt: #e0e5eb;
    $color_text: #121212;
    $color_text_alt: #36bae6;
    $color_border: #e0e5eb;
    $transition_link: .14s ease-in-out;
    $transition_anim: .22s ease-in-out;

    2. Compile the main.scss to main.css.

    sass /path/to/main.scss /path/to/main.css

    3. Load the main.css in the document.

    <link rel="stylesheet" href="main.css" />

    4. The HTML structure for the responsive sticky navbar.

    <header>
      <div class="container">
        <div class="logo">
          CSSScript
        </div>
        <input class="hamburger-button" type="checkbox" id="hamburger-button" />
        <label for="hamburger-button">
          <div></div>
        </label>
        <div class="menu">
          <nav>
            <ul>
                <li><a href="#">Home</a></li>
                <li><a href="#">About</a></li>
                <li><a href="#">Work</a></li>
                <li><a href="#">Contact</a></li>
            </ul>
          </nav>
          <div class="buttons">
            <a href="#" class="button primary">Login</a>
            <a href="#" class="button">Settings</a>
          </div>
        </div>
      </div>
    </header>
    Responsive Navigation Bar With Flexbox And JavaScript – simply-nav

    Responsive Navigation Bar With Flexbox And JavaScript – simply-nav

     

    Responsive Navigation Bar With Flexbox And JavaScript – simply-nav

    Category: Javascript , Menu & Navigation | December 30, 2020
    AUTHOR:obscuredetour
    VIEWS TOTAL:329 views
    OFFICIAL PAGE:Go to website
    LAST UPDATE:December 30, 2020
    LICENSE:MIT

    Preview:

    Responsive Navigation Bar With Flexbox And JavaScript – simply-nav

    Description:

    A simple, lightweight, sticky, fully responsive, mobile-compatible navigation system built using JavaScript and CSS flexbox.

    It automatically collapses the navigation bar into an off-canvas hamburger navigation when the screen size is smaller than a specific width.

    Sticky navigation is supported as well. It means that you can stick the navigation bar to the top or bottom of the webpage.

    Basic usage:

    Import the necessary stylesheet and JavaScript into the document.

    <link rel="stylesheet" href="nav.css">
    <script src="simply-nav.js"></script>

    The necessary HTML structure for the navigation.

    <header class="nav-wrapper">
      <nav class="nav" role="navigation">
        <span class="toggleNav">
          <svg class="svg-hamburger" viewBox="0 0 1536 1280" xmlns="http://www.w3.org/2000/svg">
            <path class="svg-hamburger-path" d="M1536 1088v128q0 26-19 45t-45 19H64q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45zm0-512v128q0 26-19 45t-45 19H64q-26 0-45-19T0 704V576q0-26 19-45t45-19h1408q26 0 45 19t19 45zm0-512v128q0 26-19 45t-45 19H64q-26 0-45-19T0 192V64q0-26 19-45T64 0h1408q26 0 45 19t19 45z"
                  fill="rgba(226, 241, 236, 20.85)" />
          </svg>
        </span> 
        <a class="nav__logo" href="#">
          <img class="logo logo-small" id="logo" src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/JavaScript-logo.png/480px-JavaScript-logo.png" alt="Logo">
        </a>
        <ul class="nav__list" id="sideNav">
          <div class="nav__list-left">
            <a class="closeBtn">
              <svg class="svg-close" viewBox="0 0 1188 1188" xmlns="http://www.w3.org/2000/svg">
                <path class="svg-close-path" d="M1188 956q0 40-28 68l-136 136q-28 28-68 28t-68-28L594 866l-294 294q-28 28-68 28t-68-28L28 1024Q0 996 0 956t28-68l294-294L28 300Q0 272 0 232t28-68L164 28q28-28 68-28t68 28l294 294L888 28q28-28 68-28t68 28l136 136q28 28 28 68t-28 68L866 594l294 294q28 28 28 68z"
                      fill="rgba(226, 241, 236, 0.85)" />
              </svg>
            </a>
            <li>
              <a class="nav__item" href="#">Home</a>
            </li>
            <li>
              <a class="nav__item" href="#">Contact</a>
            </li>
            <li>
              <a class="nav__item" href="#">About</a>
            </li>
            <li>
              <a class="nav__item" href="#">Blog</a>
            </li>
            <li>
              <a class="nav__item" href="#">Works</a>
            </li>
          </div>
          <div class="nav__list-right">
            <div class="page__overlay"></div>
          </div>
        </ul>
      </nav>
    </header>

    To create a sticky navigation, just add the -sticky class to the nav wrapper.

    <header class="nav-wrapper -sticky">
      ...
    </header>

    Stick the navigation to the bottom using the -bottom class.

    <header class="nav-wrapper -sticky -bottom">
      ...
    </header>

    Changelog:

    v1.3.1 (12/30/2020)

    • Fixed overflow bug.

    v1.3.0 (12/26/2020)

    • Left & Right side layouts now supported. Right-side is now default.
    • Refactored some SCSS, cleaned up some styles, animations, & JS.
    • No longer maintaining standalone version (legacy version will remain).
    • Due to all of the above, DOM changes occurred and a version point bump.

    Health

    [Umum][recentbylabel]