Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About wattle40802

  • Rank

Previous Fields

  • Languages
    HTML, CSS, XML, Javascript, PHP

Profile Information

  • Location
  1. Thank you to Sunamena for suggesting Bootstrap "Affix" which does achieve the effect that I am looking for. As I have gone down the W3.CSS route, though, I would prefer not to mix Bootstrap code so I have persisted with trying to solve the matter another way. I have now managed to do so simply by enclosing the nav bar div (id="nav_bar") in another div and fixing this "nav subcontainer" , rather than "nav_bar" when the page is scrolled down and it reaches the top of the viewport. I have tested this arrangement across a number of browsers and it works fine. Maybe w3.schools could include this as a variant of their w3-top (or w3-bottom) class with a suggested name of "w3-top-sticky"?
  2. I am trying to find a solution to a problem that I have encountered while trying to get a fixed-top navigation menu to work dynamically in W3.CSS. By dynamically, I mean that the horizontally-orientated navigation bar should remain in its place under the page title and image until the page is scrolled downwards and reaches the top of the viewport. At this point, it should fix itself to the top of the screen. I have been able to achieve this effect using my own html/css and jquery script but this method doesn’t work as intended with W3.CSS. I have been moving my websites over to W3.CSS as I as a means of making them responsive and also because css is not my strong point and I like the W3.CSS structure. The menu bar operates as it should when it is in its static mode but, when it is fixed, which involves position:absolute and a z-index of 1, the dropdown menus no longer appear above the bar but are concealed within it. I have tried altering the z-index values of the dropdown-hover and dropdown-content elements but cannot find a solution to this problem. If there is anyone who can, I would be very grateful. The html code below is based closely on the “Navigation Bar with Dropdown” example taken from the W3.CSS Navigation Bars page. I also include the css used to fix the bar and the jquery function to call the css once the top of the screen is reached. HTML <div id=”container”> <div id=”header”></div> <img id="header_image" src="titleimage.jpg" alt="Header Image" class="header_image"/> <img id="header_image_m" src="title_image_m.jpg" alt="Header Image" class="header_image"/> <div id=”nav_bar_container> <div id=”nav_bar” class="w3-bar w3-light-grey"> <a href="#" class="w3-bar-item w3-button w3-mobile">Home</a> <a href="#" class="w3-bar-item w3-button w3-mobile">Link 1</a> <div class="w3-dropdown-hover"> <button class="w3-button">Dropdown</button> <div class="w3-dropdown-content w3-bar-block w3-card-4 w3-mobile"> <a href="#" class="w3-bar-item w3-button">Link 1</a> <a href="#" class="w3-bar-item w3-button">Link 2</a> <a href="#" class="w3-bar-item w3-button">Link 3</a> </div> </div> </div> </div> CSS #nav_bar_container, #nav_bar{ margin:0; padding:0; width:100%; max-width:948px; } .nav_bar_fixed { position:fixed; top:0px; z-index:1; } Jquery if ($( window ).width() > 600) { $(window).scroll(function() { var fixedBar = $('#nav_bar'), targetScroll = $('#nav_bar_container').position().top, currentScroll = $('html').scrollTop() || $('body').scrollTop(); fixedBar.toggleClass('nav_bar_fixed', currentScroll >= targetScroll); }); }
  3. Thank you, "boen_robot". I was beginning to reason that only strings were readable from XML documents so your suggestion of creating date objects makes sense. I will rewrite my script accordingly. Thanks again!
  4. Hello, I am trying to write a programme to select data from my XML file by date. The example that I quote below is a database of services for our church which I would like to be presented on our web pages in such a way that only services newer than today's date or less far into the future than a date limit set by me (in this case 1 month) are visible to the viewer. Using the excellent tutorials and examples on www.w3schools.com I have been able to successfully make my XML data viewable on the web page, but not filtered by date. If anyone can tell me how to write my javascript to recognise the date attribute, I would be very grateful. Thanking you in advance. This is my XML file: <?xml version="1.0" encoding="ISO-8859-1" ?><servicesdiary> <service date="2011,10,27"> <rdate>27th November 2011</rdate> <time>10:30am</time> <type>Holy Communion</type> <theme>Advent</theme> </service> <service date="2011,10,27"> <rdate>27th November 2011</rdate> <time>6:30om</time> <type>Advent Evensong</type> <theme>Advent</theme> </service> <service date="2011,11,4"> <rdate>4th December 2011</rdate> <time>10:30am</time> <type>Holy Communion</type> <theme>Advent One</theme> </service> <service date="2011,11,11"> <rdate>11th December 2011</rdate> <time>10:30am</time> <type>Holy Communion</type> <theme>Advent Two</theme> </service> <service date="2011,11,18"> <rdate>18th December 2011</rdate> <time>10:30am</time> <type>Holy Communion</type> <theme>Advent Three</theme> </service> <service date="2011,11,25"> <rdate>25th December 2011</rdate> <time>09:30am</time> <type>Holy Communion</type> <theme>Christmas Day</theme> </service> <service date="2012,0,1"> <rdate>1st January 2012</rdate> <time>10:30am</time> <type>Holy Communion</type> <theme>Epiphany</theme> </service> <service date="2012,0,8"> <rdate>8th January 2012</rdate> <time>10:30am</time> <type>Holy Communion</type> <theme>The Baptism of Christ</theme> </service></servicesdiary> And this is my javascript script: xmlDoc=loadXMLDoc("ServicesDiary.xml"); var today=new Date();var ahead=new Date();ahead.setDate(ahead.getDate()+28); var x=xmlDoc.getElementsByTagName("service");document.write("<table border='2' width='700px' cellpadding='10'>");document.write("<tr><th>Date</th><th>Time</th><th>Type</th><th>Theme</th>");document.write("</tr>");for (i=0;i<x.length;i++){if ((x.item(i).attributes[0].value) < today) continue;if ((x.item(i).attributes[0].value) > ahead) continue; document.write("<tr><td>");document.write(x.getElementsByTagName("rdate")[0].childNodes[0].nodeValue);document.write("</td><td>"); document.write(x.getElementsByTagName("time")[0].childNodes[0].nodeValue);document.write("</td><td>"); document.write(x.getElementsByTagName("type")[0].childNodes[0].nodeValue);document.write("</td><td>"); document.write(x.getElementsByTagName("theme")[0].childNodes[0].nodeValue);document.write("</td></tr>"); }document.write("</table>");
  • Create New...