Jump to content

nickc

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by nickc

  1.  

    Unlike Bootstrap, W3.CSS does not use any Javascript. If you look at the example page, what they've done is add Javascript to it. If you look at the bottom of the page, they've defined a function called openNav().

     

    What you can do is go through each of the links and have them call openNav when clicked.

    // Get a list of links
    var links = document.querySelectorAll(".w3-navbar .w3-hide-small > a");
    
    // Loop through the links to add the event listener
    for(var i = 0; i < links.length; i++) {
      links[i].addEventListener("click", openNav, false);
    }

     

    Fabulous. It works. Thanks so much!

  2. Hello

     

    I have built a one page website based on this template - http://www.w3schools.com/w3css/tryw3css_templates_website.htm

     

    When viewed a smartphone screen the smallscreen navbar does not collapse after clicking a link and I therefore have to toggle the nav button manually.

     

    I have created a workaround in order for the site to function as desired which can be found here - http://www.davidclarkandco.co.uk/index.html - but ideally I simply wish to use a single page and have the menu to collapse on click.

     

    Thanks in advance for advice/help.

×
×
  • Create New...