我目前正在努力让我的菜单适用于移动设备/小屏幕。
这里可以看到演示> http://astuteo.com/mobilemenu/demo 缩小浏览器窗口,你会看到我希望它在我完成时的样子!
这是我的代码
<html xmlns="http://www.w3.org/1999/xhtml"xml:lang="sv">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>egen hemsida</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" media="screen" href="mobilemenu.css"/>
<link rel="stylesheet" type="text/css" href="screen.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".nav-button").on('click',function () {
$(".nav-button,.nav").toggleClass("open");
});
});
</script>
</head>
<body>
<button class="nav-button">Toggle Navigation</button>
<ul class="nav">
<li><a href="#">Program</a>
<ul>
<li><a href="#">Teknik</a></li>
<li><a href="#">Naturvetenskap</a></li>
<li><a href="#">El</a></li>
</ul></li>
<li><a href="#">Nösnäs</a></li>
<li><a href="#">Schema</a></li>
<li><a href="#">Matsal</a></li>
</ul>
<style>.xg_module_body img {margin:0!important;}</style>
<span class="bilder">
<div align="center"><table cellpadding="0" width="150" cellspacing="0"><tr>
<td><a href="#" target="_blank"><img src="facebookpic.png" title="Gilla våran Facebook sida" width="35" height="35" border="0"></a></td>
<td><a href="#"target="_blank"><img src="googlepic.png" title="Gilla oss på googlde+" width="35" height="35" border="0"></a></td>
<td><a href="#" target="_blank"><img src="twitterpic.png" title="Följ oss på Twitter" width="35" height="35" border="0"></a></td>
<td><a href="#" target=""><img src="rsspic.png" width="35" height="35" border="0" title="Följ våran RSS"></a></td>
</tr>
</table></div>
</span>
</body>
</html>
CSS - 屏幕
.bilder {
position: absolute;
top: 150px;
left: 110px;
}
* { margin:0;
padding:0;
}
html {height: 100%;}
body{
position: relative;
height: 100%;
background: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#fff));
}
.navbox {
position: -9999px -9999px;
float: left;
background-position:-9000 -9000;
}
/* Första boxarna*/
ul.nav {
list-style: none;
display: block;
width: 170px;
position: relative;
top: :0px;
left: 100px;
z-index:0;
padding: 100px 0 50px 0;
background: url(shad2.png) no-repeat;
-webkit-background-size: 50% 100%;
display: list-item;
}
li {
margin: 5px 0 0 0;
}
/* När jag drar musen över */
ul.nav li a {
-webkit-transition: all 0.3s ease-out;
color: #174867;
padding: 7px 15px 7px 15px;
-webkit-border-top-right-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
display: block;
text-decoration: none;
-webkit-box-shadow: 2px 2px 4px 2px #888;
}
ul.nav li a:hover {
background: #ebebeb url(border.png) no-repeat;
color: #67a5cd;
padding: 7px 15px 7px 30px;
}
ul.nav li ul {
display:none;
}
ul.nav li:hover ul {
display:block;
position:relative;
left:5px;top:0px;
list-style: none;
z-index:999;
}
ul.nav li ul li
{
background:#888;
}
CSS-手机版
.nav-button { display: none; } /* hide the navigation button by default */
@media only screen and (min-width: 0px) and (max-width: 475px) {
/* Navigation Button
-------------------------------------------------------- */
.nav-button {
display: block;
position: absolute;
top: 7px;
left: 7px;
width: 50px;
height: 35px;
background: url('../images/menu-icon-large.png'), -webkit-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,.2));
background: url('../images/menu-icon-large.png'), -moz-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,.2));
background: url('../images/menu-icon-large.png'), -ms-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,.2));
background: url('../images/menu-icon-large.png'), -o-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,.2));
background-position: center center;
background-repeat: no-repeat;
background-size: 21px, 100%;
cursor: pointer;
border: 0 none;
border-bottom: 1px solid rgba(255,255,255,.1);
box-shadow: 0 0 4px rgba(0,0,0,.7) inset;
border-radius: 5px;
z-index: 999;
text-indent: -9999px;
}
.nav-button:hover {
background-color: rgba(0,0,0,.1);
}
.nav-button.open {
background: url('../images/close-icon-large.png'), -webkit-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,.2));
background: url('../images/close-icon-large.png'), -moz-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,.2));
background: url('../images/close-icon-large.png'), -ms-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,.2));
background: url('../images/close-icon-large.png'), -o-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,.2));
background-position: center center;
background-repeat: no-repeat;
background-size: 21px, 100%;
}
/* Navigation Bar
-------------------------------------------------------- */
body { padding-top: 50px; }
ul.nav{
width: 100%;
float: none;
background-color: #238be3; /* change the menu color */
background-image: -webkit-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,.2));
background-image: -moz-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,.2));
background-image: -ms-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,.2));
background-image: -o-linear-gradient(top, rgba(0,0,0,0), rgba(0,0,0,.2));
display: block;
height: 50px;
margin: 0;
padding: 0;
overflow: hidden;
box-shadow: 0 1px 2px rgba(0,0,0,.6);
position: absolute;
top: 0px;
left: 0px;
z-index: 998;
clear: both;
}
ul.nav li {
display: none;
width: 100%;
font-family: Arial;
}
ul.nav li a {
display: block;
width: 90%;
padding: 10px 5%;
font-size: 14px;
font-weight: bold;
text-shadow: -1px -1px 0 rgba(0,0,0,.15);
color: white;
text-decoration: none;
border-bottom: 1px solid rgba(0,0,0,.2);
border-top: 1px solid rgba(255,255,255,.1);
}
ul.nav li a:hover {
background-color: rgba(0,0,0,.5);
border-top-color: transparent;
}
ul.nav > li:first-child {
border-top: 1px solid rgba(0,0,0,.2);
}
/* Toggle the navigation bar open */
ul.nav.open {
height: auto;
padding-top: 50px;
}
ul.nav.open li {
display: block;
}
/* Submenus – optional .parent class indicates dropdowns */
ul.nav > li:hover > a {
background: rgba(0,0,0,.5);
border-bottom-color: transparent;
}
.nav li.parent > a:after {
content: "▼";
color: rgba(255,255,255,.5);
float: right;
}
.nav li.parent > a:hover {
background: rgba(0,0,0,.75);
}
.nav li ul {
display: none;
background: rgba(0,0,0,.5);
border-top: 0 none;
padding: 0;
}
.nav li ul a {
border: 0 none;
font-size: 12px;
padding: 10px 5%;
font-weight: normal;
}
.nav li:hover ul {
display: block;
border-top: 0 none;
}
} /* End Mobile Styles */
我得到的只是一个可点击的按钮,但没有任何结果!
感谢大家的帮助! :)