【问题标题】:How can I make my top bar elements clickable in responsive?如何使我的顶部栏元素在响应中可点击?
【发布时间】:2019-10-28 07:50:25
【问题描述】:

我的顶部栏中有一个漂亮的菜单、一个徽标和一个搜索元素。不幸的是,我无法弄清楚如何在我的平板电脑和移动响应中同时使它们全部可点击。由于 z-index,我认为它们是堆叠/透明的——这就是问题所在。我只能使菜单+搜索可点击或徽标。我尝试在每个元素上将它们更改为 inline-block,尝试了 pointer-events 属性,并且还更改了 z-index 值,但没有任何成功。我该如何解决这个问题?

你可以在这里查看我的网站:www.rachelclayton.co

CSS:

@media only screen and (max-width: 767px) {
    #top-bar-logo {
    text-align: center;
    position: absolute;
}}

@media only screen and (max-width: 941px) {

#top-bar-logo {
    display: block;
}   
#top-bar-logo img {
    max-width:60%;
    height:auto;
}
#mobile-social {
    display: none;
}
    #top-bar {
    height:40px;
    position:relative;
    line-height:40px;
    background:#ffff;
    z-index:99999;
}}

@media only screen and (max-width: 490px) {
#header {
    padding-top: 10px;
    padding-bottom: 10px;
}
#top-bar {
    height:35px;
    position:relative;
    line-height:35px;
    background:#ffff;
    z-index:99999;
}
#top-bar-logo img {
    max-width:70%;
    height:auto;
}
#top-bar-logo {
    display: inline-block;
}}

【问题讨论】:

    标签: css image menu header position


    【解决方案1】:

    我很难理解这篇文章。

    具体是什么意思“当我将它移到顶部栏时,它变得不可点击。”? “上移”中的“它”是什么?

    我在你的网站上看到你用<a> 包裹了<img> - 这很好。

      <a href="https://rachelclayton.co/"><img src="https://rachelclayton.co/wp-content/uploads/2019/05/RClogo.png" alt="Rachel Clayton" /></a>
    

    您是否尝试过将&lt;div id="top-bar-logo"&gt; 也包含在&lt;a&gt; 标记中?

    【讨论】:

    • 对不起——我的意思是“它”作为图像/标志。我继续摆弄,并认为问题在于徽标的 z-index 小于 slick-navigation-menu(移动顶部栏左侧的 3 个栏)的 z-index。我尝试在徽标上设置更高的 z-index 值。现在徽标在顶部栏中是可点击的,但光滑菜单变得不可点击(因为它的 z-index 值较低)。我猜它与顶栏元素的宽度有关。我正在考虑 display: inline-block 每个元素和免费宽度或弹性框。有什么想法吗?
    • 我可以使用“指针事件”,但我不知道如何使徽标、菜单和搜索仍然可以点击。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-04
    • 2021-10-18
    • 1970-01-01
    • 2019-08-04
    • 1970-01-01
    • 2017-06-20
    相关资源
    最近更新 更多