简体   繁体   English

如何使图像栏保持在手机菜单的最上方?

[英]How can I make an image bar to stay on top with the menu on mobile?

I have downloaded the HTML5 template from http://html5up.net/prologue . 我已经从http://html5up.net/prologue下载了HTML5模板。 The template is responsive, and the navigation menu stays on top in mobile to be clicked to show the menu items. 模板是响应式的,导航菜单位于移动设备的顶部,可以单击以显示菜单项。 What I am trying to achieve is to include the image at top that would stay fixed like the menu in the mobile view. 我要实现的目标是在顶部保留像移动视图中的菜单一样固定的图像。 I have tried adding a div as below: 我试过添加div如下:

<div style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index:99;">
<img src="nameofimagefile"/>
</div>

But I am not able to achieve what I need. 但是我无法实现我所需要的。 The image stays on top but blocks or hides the menu items. 图像停留在顶部,但阻止或隐藏菜单项。 Could you help me in achieving this? 你能帮我实现这个目标吗?

The following images may make it clear on what I am trying to achieve: 下图可以清楚地说明我要实现的目标:

Present Website: 现在的网站:
现在的网站

What I Would Like: 我想要的是:
我想要什么

If you want it works only on a narrow screen do this: 如果您希望它仅在窄屏上运行,请执行以下操作:

In /js/init.js file find sidePanelToggle object and add to its html property your div with buttons /js/init.js文件中,找到sidePanelToggle对象,然后使用按钮将div添加到其html属性中

// ...
sidePanelToggle: {
                    breakpoints: 'narrower',
                    position: 'top-left',
                    side: 'top',
                    height: '4em',
                    width: '5em',
                    html: '<div data-action="toggleLayer" data-args="sidePanel" class="toggle"></div>' + '<div style="position: fixed; display: inline; top: 0; right: 5px; color: white">Your buttons here</div>'
// ...

change the 改变

#main section.cover {
    padding: 0;   /*for all the @media css*/
}

and then add image tag before the h2 tag within header tag 然后在标题标签中的h2标签之前添加图片标签

It will work ! 会工作的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使CSS菜单排在最前面 - How to make CSS menu stay on top 如何使.header和.nav固定在视口顶部? - How can I make the .header and .nav stay fixed on the top of the viewport? 对于移动Webkit,如何在触摸/拖动时使水平菜单栏滚动? - For mobile webkit, how can I make the horizontal menu bar scrollable when you touch/drag it? 如何使徽标出现在顶部固定菜单栏上,该菜单栏向下滚动时显示,回到顶部时该徽标消失? - how can i make a logo appear on a top fixed menu bar that appears when scrolled down and it should disappear when returned to top? 当查看器滚动时,如何使网站的导航栏位于顶部? - How do I make the navigation bar of my site stay at the top when the viewer scrolls? 如何在悬停时让此菜单保持在图像的右上角? - CSS,jQuery - How do I get this menu to stay top right of the image on hover? - CSS, jQuery 如何在移动视图中将最后一个div列保留在页面顶部? - how to make the last div column stay on the top of the page in mobile view? 仅滚动时,如何使导航菜单停留在页面顶部? - How to make navigation menu stay at the top of the page while scrolling only? 如何在IE6及更高版本中进行“停留在顶部”菜单? - How to make “Stay-On-Top” Menu in IE6 and above? 如何使固定的背景图像不能固定在滚动条上? - How can I make a fixed background image not stay fixed on scroll?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM