MalikDzgn: CSS & CSS3
  • Jelajahi

    Copyright © MalikDzgn -

    Quickly update interesting info starting today

    Malikdzgn

    Malikdzgn
    Affichage des articles dont le libellé est CSS & CSS3. Afficher tous les articles
    Affichage des articles dont le libellé est CSS & CSS3. Afficher tous les articles

    mercredi 24 février 2021

    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>
    Lightweight CSS Framework For Small Applications – softframecss

    Lightweight CSS Framework For Small Applications – softframecss

     

    Lightweight CSS Framework For Small Applications – softframecss

    Category: CSS & CSS3 , Frameworks | January 2, 2020
    AUTHOR:softframecss
    VIEWS TOTAL:233 views
    OFFICIAL PAGE:Go to website
    LAST UPDATE:January 2, 2020
    LICENSE:MIT

    Preview:

    Lightweight CSS Framework For Small Applications – softframecss

    Description:

    softframecss is a super tiny, pretty clean, CSS-only front-end framework designed for mobile-first web applications.

    How to use it:

    1. Insert the main stylesheet into the document and done.

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

    2. Typography.

    softframecss Typography

    <h1> This is text with <span class="sf_buttom light-gray">h1</span></h1>
    <h2> This is text with <span class="sf_buttom light-gray">h2</span></h2>
    <h3> This is text with <span class="sf_buttom light-gray">h3</span></h3>
    <h4> This is text with <span class="sf_buttom light-gray">h4</span></h4>
    <h5> This is text with <span class="sf_buttom light-gray">h5</span></h5>
    <h6> This is text with <span class="sf_buttom light-gray">h6</span></h6>
    <p>This is paragraphy <span class="sf_buttom light-gray">p</span></p>

    3. Buttons.

    softframecss Buttons

    <button class="sf_buttom light-gray">Button</button>
    <button class="sf_buttom dark-gray">Button</button>
    <button class="sf_buttom black">Button</button>
    <button class="sf_buttom success">Button</button>
    <button class="sf_buttom danger">Button</button>
    <button class="sf_buttom warning">Button</button>

    4. Badges.

    softframecss Badges

    <button class="sf_buttom blue"> cart <span class="sf_badge white">2</span> </button>
    <button class="sf_buttom dark-gray"> messages <span class="sf_badge white">12</span> </button>
    <button class="sf_buttom danger"> likes <span class="sf_badge white">34</span> </button>

    5. Breadcrumb.

    softframecss breadcrumb

    <nav class="sf_breadcrumb">
      <ul>
        <li>Music</li>
        <li>Rock</li>
        <li>Wolves At The Gate</li>
        <li>Heralds</li>
      </ul>
    </nav>

    6. Grid layout.

    softframecss Layout

    <div class="sf_card sf1">
      <h3 class="text-center ps5"> sf1 </h3>
    </div>
    <div class="sf_card sf1">
      <h3 class="text-center ps5"> sf1 </h3>
    </div>
    <div class="sf_card sf1">
      <h3 class="text-center ps5"> sf1 </h3>
    </div>
    <div class="sf_card sf1">
      <h3 class="text-center ps5"> sf1 </h3>
    </div>
    <div class="sf_card sf1">
      <h3 class="text-center ps5"> sf1 </h3>
    </div>
    <div class="sf_card sf1">
      <h3 class="text-center ps5"> sf1 </h3>
    </div>
    <div class="sf_card sf1">
      <h3 class="text-center ps5"> sf1 </h3>
    </div>
    <div class="sf_card sf1">
      <h3 class="text-center ps5"> sf1 </h3>
    </div>
    <div class="sf_card sf1">
      <h3 class="text-center ps5"> sf1 </h3>
    </div>
    <div class="sf_card sf1">
      <h3 class="text-center ps5"> sf1 </h3>
    </div>
    <div class="sf_card sf1">
      <h3 class="text-center ps5"> sf1 </h3>
    </div>
    <div class="sf_card sf1">
      <h3 class="text-center ps5"> sf1 </h3>
    </div>

    7. Form fields.

    softframecss Form

    <form action="" class="sf_form">
      <fieldset> 
          <legend> fieldset</legend>
          <ul>
              <li>assigns <strong>sf_input</strong> to each input </li>
              <li>each <strong>sf_input</strong> must contain a <strong>label</strong> and an <strong>input</strong></li>
              <li>the <strong>inputs</strong> inherit width from <strong>sf_input</strong></li>
          </ul>
          <div class="sf12_i">
              <div class="sf_input sf5_i">
                  <label for="name">Name</label>
                  <input type="text" name="name">
              </div>
              <div class="sf_input sf5_i">
                  <label for="surname">Surname</label>
                  <input type="text" name="surname">
              </div>
              <div class="sf_input sf2_i">
                  <label for="age">Age</label>
                  <input type="text" name="age">
              </div>
          </div>
          <div class="sf12_i">
              <div class="sf_input sf1_i">
                  <label for="job">Job</label>
                  <input type="text" name="job">
              </div>
              <div class="sf_input sf3_i">
                  <label for="company">Company</label>
                  <input type="text" name="company">
              </div>
              <div class="sf_input sf3_i">
                  <label for="employee">Employees</label>
                  <input type="text" name="employee">
              </div>
              <div class="sf_input sf5_i">
                  <label for="tags">Tags</label>
                  <input type="text" name="tags">
              </div>
          </div>
          <div class="sf12_i">
              <button class="sf_buttom success">Submit brow</button>
          </div>
      </fieldset>
    </form>

    8. Modal.

    softframecss modal

    <label class="sf_buttom dark-gray" for="modal">Open modal</label>
    <input class="sf_modal_state" id="modal" type="checkbox" hidden>
    <div class="sf_modal">
      <label class="sf_modal_bg" for="modal"></label>
      <div class="sf_modal_inner">
          <label class="sf_modal_close" for="modal"></label>
          <h2>Hello, i'm modal</h2>
          <p>
              this project is Brazilian
          </p>
      </div>
    </div>

    mercredi 17 février 2021

       Responsive Header Dropdown Navigation Bar With JavaScript and CSS

    Responsive Header Dropdown Navigation Bar With JavaScript and CSS

     

    Responsive Header Dropdown Navigation Bar With JavaScript and CSS

    Category: Javascript , Menu & Navigation | October 2, 2020
    AUTHOR:bedimcode
    VIEWS TOTAL:864 views
    OFFICIAL PAGE:Go to website
    LAST UPDATE:October 2, 2020
    LICENSE:MIT

    Preview:

    Responsive Header Dropdown Navigation Bar With JavaScript and CSS

    Description:

    Just another responsive navbar system that collapses items in a horizontal multi-level menu into a mobile-friendly sidebar navigation with dropdowns on the mobile.

    How to use it:

    1. Insert a multi-level navbar into your header. It uses box icons for the toggle and dropdown icons in this example.

    <header class="header">
      <a href="#" class="header__logo">Site Name</a>
      <i class='bx bx-menu header__toggle' id="header-toggle"></i>
      <nav class="nav" id="nav-menu">
        <div class="nav__content bd-grid">
          <a href="" class="nav__perfil">
            <div class="nav__img">
              Your Logo Here
            </div>
            <div>
              <span class="nav__name">CSS</span>
              <span class="nav__name">Script</span>
            </div>
          </a>
          <div class="nav__menu">
            <ul class="nav__list">
              <li class="nav__item"><a href="#" class="nav__link active">Home</a></li>
              <li class="nav__item dropdown">
                <a href="#" class="nav__link dropdown__link">About <i class='bx bx-chevron-down dropdown__icon'></i></a>
                <ul class="dropdown__menu">
                  <li class="dropdown__item"><a href="#" class="nav__link">About me</a></li>
                  <li class="dropdown__item"><a href="#" class="nav__link">Location</a></li>
                  <li class="dropdown__item"><a href="#" class="nav__link">Studies</a></li>
                </ul>
              </li>
              <li class="nav__item"><a href="#" class="nav__link">Skills</a></li>
              <li class="nav__item dropdown">
                <a href="#" class="nav__link dropdown__link">Works <i class='bx bx-chevron-down dropdown__icon'></i></a>
                <ul class="dropdown__menu">
                  <li class="dropdown__item"><a href="#" class="nav__link">Recent jobs</a></li>
                  <li class="dropdown__item"><a href="#" class="nav__link">Better jobs</a></li>
                  <li class="dropdown__item"><a href="#" class="nav__link">Work Awards</a></li>
                </ul>
              </li>
              <li class="nav__item"><a href="#" class="nav__link">Contact</a></li>
            </ul>
          </div>
        </div>
      </nav>
    </header>

    2. The main CSS for the responsive navbar.

    /*===== VARIABLES CSS =====*/
    :root {
      --header-height: 3rem;
    
      /*===== Colors =====*/
      --first-color: #5B65F5;
      --first-color-light: #C4C7F5;
      --dark-color: #0E1026;
      --white-color: #FBFBFB;
    
      /*===== Font and typography =====*/
      --body-font: 'Open Sans', sans-serif;
      --nav-name-font-size: 1.5rem;
      --normal-font-size: .938rem;
    
      /*===== z index =====*/
      --z-fixed: 100;
    }
    
    @media screen and (min-width: 768px) {
      :root {
        --nav-name-font-size: 1rem;
        --normal-font-size: 1rem;
      }
    }
    
    .header {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: var(--header-height);
      padding: 0 1rem;
      background-color: #FFF;
      z-index: var(--z-fixed);
      display: flex;
      justify-content: space-between;
      align-items: center;
      box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .header__logo {
      color: var(--dark-color);
    }
    
    .header__toggle {
      font-size: 1.7rem;
      cursor: pointer;
    }
    
    /*===== NAV =====*/
    @media screen and (max-width: 768px) {
      .nav {
        position: fixed;
        top: 0;
        left: -100%;
        background-color: var(--first-color);
        width: 80%;
        height: 100vh;
        padding: 2rem 0;
        z-index: var(--z-fixed);
        transition: .5s;
        overflow-y: auto;
      }
    }
    
    .nav__content {
      display: flex;
      flex-direction: column;
    }
    
    .nav__perfil {
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
      margin-bottom: 3rem;
    }
    
    .nav__img {
      display: flex;
      justify-content: center;
      width: 60px;
      height: 60px;
      border-radius: 50%;
      overflow: hidden;
      margin-bottom: 1rem;
    }
    
    .nav__img img {
      width: 70px;
    }
    
    .nav__name {
      display: block;
      font-size: var(--nav-name-font-size);
      color: var(--white-color);
    }
    
    .nav__item {
      margin-bottom: 2rem;
    }
    
    .nav__link {
      color: var(--first-color-light);
    }
    
    .nav__link:hover {
      color: var(--white-color);
    }
    
    /*Show menu*/
    .show {
      left: 0;
    }
    
    /*Active link*/
    .active {
      color: var(--white-color);
    }
    
    /*=== Dropdown ===*/
    .dropdown__link {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    
    .dropdown__icon {
      font-size: 1.3rem;
      transition: .5s;
    }
    
    .dropdown__menu {
      margin: 1rem 0 0 1rem;
      display: none;
    }
    
    .dropdown__item {
      margin: 1rem 0;
    }
    
    .dropdown:hover > .dropdown__menu {
      display: block;
    }
    
    .dropdown:hover .dropdown__icon {
      transform: rotate(180deg);
    }
    
    /* ===== MEDIA QUERIES=====*/
    @media screen and (min-width: 576px) {
      .nav {
        width: 288px;
      }
    }
    
    @media screen and (min-width: 768px) {
      body {
        margin: 0;
      }
      .header {
        height: calc(var(--header-height) + 1rem);
      }
      .header__logo, .header__toggle {
        display: none;
      }
      .nav {
        width: 100%;
      }
      .nav__content {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
      }
      .nav__perfil {
        flex-direction: row;
        text-align: initial;
        margin-bottom: 0;
      }
      .nav__img {
        width: 40px;
        height: 40px;
        margin-right: .5rem;
        margin-bottom: 0;
      }
      .nav__img img {
        width: 46px;
      }
      .nav__name {
        color: var(--dark-color);
      }
      .nav__list {
        display: flex;
        align-items: center;
      }
      .nav__item {
        margin: 0 1.5rem;
        padding: 1.4rem 0;
      }
      .nav__link {
        color: var(--dark-color);
      }
      .nav__link:hover {
        color: var(--first-color);
      }
      /*Active link new color*/
      .active {
        color: var(--first-color);
      }
      .dropdown {
        position: relative;
      }
      .dropdown__menu {
        position: fixed;
        margin: 0;
        top: calc(var(--header-height) + 1rem);
        padding: .5rem 1.5rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        border-radius: .5rem;
      }
      .dropdown__item {
        margin: .5rem 0;
      }
    }
    
    @media screen and (min-width: 1024px) {
      .bd-grid {
        margin-left: auto;
        margin-right: auto;
      }
    }

    3. The JavaScript to enable the responsive navbar.

    const showMenu = (toggleId, navId)=>{
          const toggle = document.getElementById(toggleId),
          nav = document.getElementById(navId)
          if(toggle && nav){
            toggle.addEventListener('click', ()=>{
              nav.classList.toggle('show')
              toggle.classList.toggle('bx-x')
            })
          }
    }
    showMenu('header-toggle','nav-menu')
    const navLink = document.querySelectorAll('.nav__link');   
    function linkAction(){
      navLink.forEach(n => n.classList.remove('active'));
      this.classList.add('active');
    }
    navLink.forEach(n => n.addEventListener('click', linkAction));