- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我使用 Pushy off-canvas menu对于我的网站,它工作得很好,但它给我固定的 div header 带来了麻烦。当我向下滚动页面时,标题会完美地贴在顶部,但是一旦我打开 Canvas 外菜单,我的标题就会消失?当我关闭我的 Canvas 外菜单时,它会突然回来。看起来很奇怪。
您可以查看(密码笔)live demo of my problem, here.或者直接运行下面的代码片段。
我希望它在 Canvas 外菜单打开时保持可见。帮助将不胜感激。
提前致谢。
/*! Pushy - v1.0.0 - 2016-3-1
* Pushy is a responsive off-canvas navigation menu using CSS transforms & transitions.
* https://github.com/christophery/pushy/
* by Christopher Yee */
(function($) {
var pushy = $('.pushy'), //menu css class
body = $('body'),
container = $('#container'), //container css class
push = $('.push'), //css class to add pushy capability
pushyLeft = 'pushy-left', //css class for left menu position
pushyOpenLeft = 'pushy-open-left', //css class when menu is open (left position)
pushyOpenRight = 'pushy-open-right', //css class when menu is open (right position)
siteOverlay = $('.site-overlay'), //site overlay
menuBtn = $('.menu-btn, .pushy-link'), //css classes to toggle the menu
menuSpeed = 200, //jQuery fallback menu speed
menuWidth = pushy.width() + 'px', //jQuery fallback menu width
submenuClass = '.pushy-submenu',
submenuOpenClass = 'pushy-submenu-open',
submenuClosedClass = 'pushy-submenu-closed',
submenu = $(submenuClass);
function togglePushy() {
//add class to body based on menu position
if (pushy.hasClass(pushyLeft)) {
body.toggleClass(pushyOpenLeft);
} else {
body.toggleClass(pushyOpenRight);
}
}
function openPushyFallback() {
//animate menu position based on CSS class
if (pushy.hasClass(pushyLeft)) {
body.addClass(pushyOpenLeft);
pushy.animate({
left: "0px"
}, menuSpeed);
container.animate({
left: menuWidth
}, menuSpeed);
//css class to add pushy capability
push.animate({
left: menuWidth
}, menuSpeed);
} else {
body.addClass(pushyOpenRight);
pushy.animate({
right: '0px'
}, menuSpeed);
container.animate({
right: menuWidth
}, menuSpeed);
push.animate({
right: menuWidth
}, menuSpeed);
}
}
function closePushyFallback() {
//animate menu position based on CSS class
if (pushy.hasClass(pushyLeft)) {
body.removeClass(pushyOpenLeft);
pushy.animate({
left: "-" + menuWidth
}, menuSpeed);
container.animate({
left: "0px"
}, menuSpeed);
//css class to add pushy capability
push.animate({
left: "0px"
}, menuSpeed);
} else {
body.removeClass(pushyOpenRight);
pushy.animate({
right: "-" + menuWidth
}, menuSpeed);
container.animate({
right: "0px"
}, menuSpeed);
push.animate({
right: "0px"
}, menuSpeed);
}
}
function toggleSubmenu() {
//hide submenu by default
$(submenuClass).addClass(submenuClosedClass);
$(submenuClass).on('click', function() {
var selected = $(this);
if (selected.hasClass(submenuClosedClass)) {
//hide opened submenus
$(submenuClass).addClass(submenuClosedClass).removeClass(submenuOpenClass);
//show submenu
selected.removeClass(submenuClosedClass).addClass(submenuOpenClass);
} else {
//hide submenu
selected.addClass(submenuClosedClass).removeClass(submenuOpenClass);
}
});
}
function toggleSubmenuFallback() {
//hide submenu by default
$(submenuClass).addClass(submenuClosedClass);
submenu.children('a').on('click', function(event) {
event.preventDefault();
$(this).toggleClass(submenuOpenClass)
.next('.pushy-submenu ul').slideToggle(200)
.end().parent(submenuClass)
.siblings(submenuClass).children('a')
.removeClass(submenuOpenClass)
.next('.pushy-submenu ul').slideUp(200);
});
}
//checks if 3d transforms are supported removing the modernizr dependency
var cssTransforms3d = (function csstransforms3d() {
var el = document.createElement('p'),
supported = false,
transforms = {
'webkitTransform': '-webkit-transform',
'OTransform': '-o-transform',
'msTransform': '-ms-transform',
'MozTransform': '-moz-transform',
'transform': 'transform'
};
// Add it to the body to get the computed style
document.body.insertBefore(el, null);
for (var t in transforms) {
if (el.style[t] !== undefined) {
el.style[t] = 'translate3d(1px,1px,1px)';
supported = window.getComputedStyle(el).getPropertyValue(transforms[t]);
}
}
document.body.removeChild(el);
return (supported !== undefined && supported.length > 0 && supported !== "none");
})();
if (cssTransforms3d) {
//make menu visible
pushy.css({
'visibility': 'visible'
});
//toggle submenu
toggleSubmenu();
//toggle menu
menuBtn.on('click', function() {
togglePushy();
});
//close menu when clicking site overlay
siteOverlay.on('click', function() {
togglePushy();
});
} else {
//add css class to body
body.addClass('no-csstransforms3d');
//hide menu by default
if (pushy.hasClass(pushyLeft)) {
pushy.css({
left: "-" + menuWidth
});
} else {
pushy.css({
right: "-" + menuWidth
});
}
//make menu visible
pushy.css({
'visibility': 'visible'
});
//fixes IE scrollbar issue
container.css({
"overflow-x": "hidden"
});
//keep track of menu state (open/close)
var opened = false;
//toggle submenu
toggleSubmenuFallback();
//toggle menu
menuBtn.on('click', function() {
if (opened) {
closePushyFallback();
opened = false;
} else {
openPushyFallback();
opened = true;
}
});
//close menu when clicking site overlay
siteOverlay.on('click', function() {
if (opened) {
closePushyFallback();
opened = false;
} else {
openPushyFallback();
opened = true;
}
});
}
}(jQuery));
body {
margin: 0px;
}
div.header {
padding: 10px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
position: fixed;
top: 0;
width: 100%;
height: 40px;
background: white;
z-index: 100;
}
div.content {
padding-top: 70px;
padding-left: 300px;
padding-right: 300px;
}
div.menu-btn {
float: left;
font-size: 20px;
}
/*! Pushy - v1.0.0 - 2016-3-1
* Pushy is a responsive off-canvas navigation menu using CSS transforms & transitions.
* https://github.com/christophery/pushy/
* by Christopher Yee */
/* Menu Appearance */
.pushy {
position: fixed;
width: 200px;
height: 100%;
top: 0;
z-index: 9999;
background: #191918;
overflow: auto;
visibility: hidden;
-webkit-overflow-scrolling: touch;
/* enables momentum scrolling in iOS overflow elements */
}
.pushy a {
display: block;
color: #b3b3b1;
padding: 15px 30px;
text-decoration: none;
outline: 0;
}
.pushy a:hover {
color: #FFF;
}
.pushy ul:first-child {
margin-top: 10px;
}
.pushy.pushy-left {
left: 0;
}
.pushy.pushy-right {
right: 0;
}
/* Menu Movement */
.pushy-left {
-webkit-transform: translate3d(-200px, 0, 0);
-ms-transform: translate3d(-200px, 0, 0);
transform: translate3d(-200px, 0, 0);
}
.pushy-open-left #container,
.pushy-open-left .push {
-webkit-transform: translate3d(200px, 0, 0);
-ms-transform: translate3d(200px, 0, 0);
transform: translate3d(200px, 0, 0);
}
.pushy-right {
-webkit-transform: translate3d(200px, 0, 0);
-ms-transform: translate3d(200px, 0, 0);
transform: translate3d(200px, 0, 0);
}
.pushy-open-right #container,
.pushy-open-right .push {
-webkit-transform: translate3d(-200px, 0, 0);
-ms-transform: translate3d(-200px, 0, 0);
transform: translate3d(-200px, 0, 0);
}
.pushy-open-left .pushy,
.pushy-open-right .pushy {
-webkit-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
/* Menu Transitions */
#container,
.pushy,
.push {
transition: transform 0.2s cubic-bezier(0.16, 0.68, 0.43, 0.99);
}
/* Site Overlay */
.site-overlay {
display: none;
}
.pushy-open-left .site-overlay,
.pushy-open-right .site-overlay {
display: block;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 9998;
background-color: rgba(0, 0, 0, 0.5);
-webkit-animation: fade 500ms;
animation: fade 500ms;
}
@keyframes fade {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@-webkit-keyframes fade {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
/* Submenu Appearance */
.pushy-submenu {
/* Submenu Icon */
}
.pushy-submenu ul {
padding-left: 15px;
transition: max-height 0.2s ease-in-out;
}
.pushy-submenu ul .pushy-link {
transition: opacity 0.2s ease-in-out;
}
.pushy-submenu > a {
position: relative;
}
.pushy-submenu > a::after {
content: '';
display: block;
height: 11px;
width: 8px;
position: absolute;
top: 50%;
right: 15px;
background: url("../img/arrow.svg") no-repeat;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
transition: transform 0.2s;
}
/* Submenu Movement */
.pushy-submenu-closed ul {
max-height: 0;
overflow: hidden;
}
.pushy-submenu-closed .pushy-link {
opacity: 0;
}
.pushy-submenu-open {
/* Submenu Icon */
}
.pushy-submenu-open ul {
max-height: 1000px;
}
.pushy-submenu-open .pushy-link {
opacity: 1;
}
.pushy-submenu-open a::after {
-webkit-transform: translateY(-50%) rotate(90deg);
-ms-transform: translateY(-50%) rotate(90deg);
transform: translateY(-50%) rotate(90deg);
}
.no-csstransforms3d .pushy-submenu-closed ul {
max-height: none;
display: none;
}
/*# sourceMappingURL=pushy.css.map */
<!-- jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<body>
<!-- Pushy Menu -->
<nav class="pushy pushy-left">
</nav>
<!-- Site Overlay -->
<div class="site-overlay"></div>
<!-- Your Content -->
<div id="container">
<div class="header">
<div class="menu-btn">☰ Sroll down a bit and Click me, I vanish (get stuck at top)</div>
</div>
<div align="center" class="content">
<h1> Lorem Ipsum </h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium
quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras
dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius
laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque
sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis
leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium
quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras
dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius
laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque
sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis
leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium
quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras
dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius
laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque
sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis
leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium
quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras
dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius
laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque
sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis
leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium
quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras
dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius
laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque
sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis
leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc,</p>
</div>
</div>
</body>
</html>
最佳答案
有一个关闭的issue关于那个爱出风头的:
The trick is to have any fixed position (like a fixed header) elements outside of the container div. See the demo.html for examples.
在您的案例中,将 .header
移到 #container
之外是可行的。
如果您对造成这种情况的原因感兴趣,请参阅 this answer .
关于javascript - 为什么我的非 Canvas 菜单在打开时将我的固定 div 推出框架?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38804755/
我需要开发一个简单的网站,我通常使用 bootstrap CSS 框架,但是我想使用 Gumbyn,它允许我使用 16 列而不是 12 列。 我想知道是否: 我可以轻松地改变绿色吗? 如何使用固定布局
这个问题在这里已经有了答案: 关闭 13 年前。 与直接编写 PHP 代码相比,使用 PHP 框架有哪些优点/缺点?
我开发了一个 Spring/JPA 应用程序:服务、存储库和域层即将完成。 唯一缺少的层是网络层。我正在考虑将 Playframework 2.0 用于 Web 层,但我不确定是否可以在我的 Play
我现有的 struts Web 应用程序具有单点登录功能。然后我将使用 spring 框架创建一个不同的 Web 应用程序。然后想要使用从 struts 应用程序登录的用户来链接新的 spring 应
我首先使用Spark框架和ORMLite处理网页上表单提交的数据,在提交中文字符时看到了unicode问题。我首先想到问题可能是由于ORMLite,因为我的MySQL数据库的字符集已设置为使用utf8
我有一个使用 .Net 4.5 功能的模块,我们的应用程序也适用于 XP 用户。所以我正在考虑将这个 .net 4.5 依赖模块移动到单独的项目中。我怎样才能有一个解决方案,其中有两个项目针对不同的版
我知道这是一个非常笼统的问题,但我想我并不是真的在寻找明确的答案。作为 PHP 框架的新手,我很难理解它。 Javascript 框架,尤其是带有 UI 扩展的框架,似乎通过将 JS 代码与设计分开来
我需要收集一些关于现有 ORM 解决方案的信息。 请随意编写任何编程语言。 你能谈谈你用过的最好的 ORM 框架吗?为什么它比其他的更好? 最佳答案 我使用了 NHibernate 和 Entity
除了 Apple 的 SDK 之外,还有什么强大的 iPhone 框架可供开始开发?有没有可以加快开发时间的方法? 最佳答案 此类框架最大的是Three20 。 Facebook 和许多其他公司都使用
有人可以启发我使用 NodeJS 的 Web 框架吗?我最近开始从免费代码营学习express js,虽然一切进展顺利,但我对express到底是什么感到困惑。是全栈框架吗?纯粹是为了后端吗?我发现您
您可以推荐哪种 Ajax 框架/工具包来构建使用 struts 的 Web 应用程序的 GUI? 最佳答案 我会说你的 AJAX/javascript 库选择应该较少取决于你的后端是如何实现的,而更多
我有生成以下错误的 python 代码: objc[36554]: Class TKApplication is implemented in both /Library/Frameworks/Tk.
首先,很抱歉,如果我问的问题很明显,因为我没有编程背景,那我去吧: 我想运行一系列测试场景并在背景部分声明了几个变量(我打印它们以仔细检查它们是否已正确声明),第一个是整数,另外两个字符串为你可以看到
在我们承担的一个项目中,我们正在寻找一个视频捕获和录制库。我们的基础工作(基于 google 搜索)表明 vlc (libvlc)、ffmpeg (libavcodec) 和 gstreamer 是三
我试过没有运气的情况下寻找某种功能来杀死/中断Play中的正常工作!框架。 我想念什么吗?还是玩了!实际没有添加此功能? 最佳答案 Java stop类中没有像Thread方法那样的东西,由于种种原因
我们希望在我们的系统中保留所有重大事件的记录。例如,在数据库可能存储当前用户状态的地方,事件日志应记录对该状态的所有更改以及更改发生的时间。 事件记录工具应该尽可能接近于事件引发器的零开销,应该容纳结
那里有 ActionScript 2.0/3.0 的测试框架列表吗? 最佳答案 2010-05-18 更新 由于这篇文章有点旧,而且我刚刚收到了赞成票,因此可能值得提供一些更新的信息,这样人们就不会追
我有一个巨大的 numpy 数组列表(一维),它们是不同事件的时间序列。每个点都有一个标签,我想根据其标签对 numpy 数组进行窗口化。我的标签是 0、1 和 2。每个窗口都有一个固定的大小 M。
我是 Play 的新手!并编写了我的第一个应用程序。这个应用程序有一组它依赖的 URL,从 XML 响应中提取数据并返回有效的 URL。 此应用程序需要在不同的环境(Dev、Staging 和 Pro
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
我是一名优秀的程序员,十分优秀!