如何创建固定在左下角的菜单?

时间:2015-07-29 06:03:56

标签: html css

我正在寻找如何创建这样的菜单http://www.panic.lv/en/。菜单必须在左角固定,因此菜单可以保持滚动。当我使用本网站的CSS时

#nav-corner {
    width: 100%;
    height: 5em;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 800;
    overflow: hidden;
    -o-transform: skewY(-10deg);
    transform: skewY(-10deg);
}

我在我的网站上得到了这个 http://www.awesomescreenshot.com/image/443096/8c36574b9c0461dbd40f92ecb4257485

菜单不在左上角,当我缩小宽度时,他正在移动我的角落,但没有宽度:100%我失去了我的角落和平。我只能使用top:-170解决这个问题,并添加高度,例如220px;但这是一个糟糕的解决方案,因为响应速度快,在较小的分辨率下,我失去了我的偶像。

有人可以帮帮我吗?

谢谢!

1 个答案:

答案 0 :(得分:1)

你可以用这个

menu



body{
  background-color: #000000;
}
#wrapper {
    width: 100%;
    text-align: left;
    height: auto;
    min-height: 100%;
    position: relative;
}
* {
    box-sizing: border-box;
}
.menu-space {
    position: fixed;
    height: 203px;
    top: 0px;
    left: 0px;
    z-index: 800;
    overflow: hidden;
    transform: rotate(-10deg) translate(-50px, -177px);
    padding: 43px;
    width: calc(100% + 100px);
    background: #FFF none repeat scroll 0% 0%;
}
.menu-icon {
    position: fixed;
    height: 5em;
    top: 1.25em;
    left: 1.25em;
    z-index: 800;
    overflow: hidden;
    -o-transform: skewY(-10deg);
    transform: skewY(-10deg);
}

<div id="wrapper">
	<div class="menu-space"></div>
	<span class="menu-icon"><img src="http://motiongiraffx.com/wp-content/themes/motiongiraffx/images/menu-icon.png" id="nav-icon" onclick="changeImage()" alt="Menu icon"></span>
</div>

<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
&#13;
&#13;
&#13;

使用此代码,您可以删除top: -170px我使用transform: rotate(-10deg) translate(-50px, -177px);代替transform: skewY(-10deg);以及html和css中的其他小变化

可以在此处查看http://liveweave.com/WQZWpX

可以解决手机中的问题,只需要将position: fixed;width: calc(100% + 100px);添加到.responsive-menu

.responsive-menu {
    display: none;
    position: fixed;
    z-index: 900;
    width: calc(100% + 100px);
}

并为解决小问题跟着我

。在@media only screen and (max-width: 640px) {

中将@media only screen and (max-width: 630px) {更改为media-query.css

。将此css添加到media-query.css文件

@media (min-width: 550px) and (max-width: 639px) {
  .resp-menu-space {
    height: 66px;
  }
}

测试它

相关问题