0

Pls my pple this code is showing on my computer notepad

<!DOCTYPE html> <html> <head> <style> body {margin:0;} ul.topnav { list-style-type: none; margin: 0; padding: 0; overflow: hidden; background-color: #333; } ul.topnav li {float: left;} ul.topnav li a { display: inline-block; color: #f2f2f2; text-align: center; padding: 14px 16px; text-decoration: none; transition: 0.3s; font-size: 17px; } ul.topnav li a:hover {background-color: #555;} ul.topnav li.icon {display: none;} @media screen and (max-width:680px) { ul.topnav li:not(:first-child) {display: none;} ul.topnav li.icon { float: right; display: inline-block; } } @media screen and (max-width:680px) { ul.topnav.responsive {position: relative;} ul.topnav.responsive li.icon { position: absolute; right: 0; top: 0; } ul.topnav.responsive li { float: none; display: inline; } ul.topnav.responsive li a { display: block; text-align: left; } } </style> </head> <body> <ul class="topnav" id="myTopnav"> <li><a class="active" href="#home">Home</a></li> <li><a href="#news">News</a></li> <li><a href="#contact">Contact</a></li> <li><a href="#about">About</a></li> <li class="icon"> <a href="javascript:void(0);" style="font-size:15px;" onclick="myFunction()">☰</a> </li> </ul> <div style="padding-left:16px"> <h2>Responsive Topnav Example</h2> <p>Resize the browser window to see how it works.</p> </div> <script> function myFunction() { var x = document.getElementById("myTopnav"); if (x.className === "topnav") { x.className += " responsive"; } else { x.className = "topnav"; } } </script> </body> </html>

23rd Oct 2016, 12:02 PM
yommy
yommy - avatar
5 Respuestas
+ 2
I've had a quick skim through. Your code should work, I would suggest placing your CSS in an external file and linking to it, the same with JavaScript if possible. Save your file with the .html extension. Example: index.html If it still doesn't open in your default browser, right click > open with > browser. Hope this helps! Happy coding. Edit: Sometimes the .txt extension is hidden, and so you will see index.html, however it will be index.html.txt which could be the cause of your problem. There is a setting that should prevent this from happening.
23rd Oct 2016, 2:30 PM
James Welch
James Welch - avatar
+ 1
JavaScript can be in head as well as in body section Your code for JavaScript is correct
24th Oct 2016, 9:45 AM
Vipra Chudasama
Vipra Chudasama - avatar
0
I would put your CSS into a external file named Example syle.css I am not 100% sure but doesnt javascript have to be in the head section?
23rd Oct 2016, 1:43 PM
Brian
0
I mean is showing anything or not display anything
30th Nov 2016, 6:49 PM
yommy
yommy - avatar