【问题标题】:CSS sliding is overlapping to sticky top menu barCSS滑动与粘性顶部菜单栏重叠
【发布时间】:2020-04-21 19:49:39
【问题描述】:

逻辑是在滚动时粘贴菜单栏第二个 div,其他 div 应该放在粘性菜单栏下。但是这里只有第 3 个 div 滑动横幅与粘性重叠,其他的工作正常。

有人可以帮忙解决这个问题吗?

所有 div 都在 react Router 内。

CSS

  .sticky {
      width: 100%;
      height: 75px;
      color: #61dafb;
    background-color: blue;
      position: sticky;
      top: 0;
      }
    .slider-main {
        width: 100%;
        height: 500px;
        overflow: hidden;
        position: relative;
        background-image: url(../images/slide_1.jpg);
        background-repeat: no-repeat;
        background-size: cover;

        animation: slide 10s infinite;
      }
      @keyframes slide {
        0%{
          background-image: url(../images/slide_1.jpg);
          width: auto;
          height: 500px;
        }
        26%{
          width: auto;
          height: 500px;
          background-image: url(../images/slide_2.jpg);

        }
       67%{
        width: auto;
        height: 500px;
          background-image: url(../images/slide_3.jpg);
        }

      }
    /* slider text 1*/
    .tx-anim-1{
      width: 457px;
      height: 76px;
      margin: auto;
      background-image: url(../images/slider-tx-bg.png);

      text-align: center;
      color:yellow;
      font-size: 50px;
      position: relative;
      animation: mymove1 4s ;
      animation-delay: 2s;
      animation-fill-mode: both;
    }

    @keyframes mymove1 {
      from {top: -10%;}
      to {top: 64%;}
    }
    /* slider text 2*/
    .tx-anim-2{
      width: 457px;
      height: 35px;
      margin-top: 320px;
      text-align: center;
      background-image: url(../images/slider-tx-bg.png);
      color: #54ff00;
      font-size: 22px;
      position: relative;
      animation: mymove2 4s ;
      animation-delay: 2s;
      animation-fill-mode: both;

    }

    @keyframes mymove2 {
      from {left: -30%;}
      to {left: 35%;}
    }
    /* slider text 3*/
    .tx-anim-3{
      width: 550px;
      height: 35px;
     margin-top: 150px;
      margin-left: 32%;

      background-image: url(../images/slider-tx-bg.png);
      text-align: center;
      color:yellow;
      font-size: 18px;
      position: relative;
      animation: mymove3 4s ;
      animation-delay: 2s;
      animation-fill-mode: both;
    }

    @keyframes mymove3 {
      from {bottom: 0%;}
      to {bottom: 30%;}
    }

第一格

            <div>
                <div>
                    PU AMD AM4 Socket for AMD Ryzen/ AMD Ryzen 2nd Generation/Ryzen with Radeon Vega Graphics/Ryzen 1st
                    Generation/7th Generation A-series/Athlon X4/Athlon Processors Supports CPU up to 8 cores. The maximum memory frequency
                </div>
            </div>

第二格

         <div className="mycontainer sticky">
                <Navbar className=" site-bg  " expand="lg">
                    <Navbar.Brand>
                        <div>
                            <img src={logo} alt="logo" width="200" />
                            {/*   <img src={process.env.PUBLIC_URL + "./images/logo.png"} alt="mypic" width="200" /> */}
                        </div>
                    </Navbar.Brand>

                    <Navbar.Toggle className="border-0" aria-controls="navbar-toggle" />
                    <Navbar.Collapse id="navbar-toggle" bsStyle="tabs" style={{ marginTop: 30 }}>
                        <Nav className="ml-auto">
                            <Link className="my-navbar" to="/">Home</Link>
                            <Link className="my-navbar" to="/about">About</Link>
                            <Link className="my-navbar" to="/services">Services</Link>
                            <Link className="my-navbar" to="/contact">Contact</Link>
                            <Link className="my-navbar" to="/galleries">Galleries</Link>

                        </Nav>
                    </Navbar.Collapse>
                </Navbar>
            </div>

第三格

<div className="slider-main">
            <div className="tx-anim-1">
                <div>
                    Decor and Event
                </div>
            </div>
            <div className="tx-anim-2">
                <div style={{ paddingTop: 5 }}>
                    A management Company
                </div>
            </div>
            <div className="tx-anim-3">
                <div style={{ paddingTop: 5 }}>
                    We promise you the best Deal with full Satisfaction.
                </div>
            </div>

        </div>

第四格

            <div style={{ paddingTop: 50 }}>
                <Route defaultActiveKey="/home" path="/" exact render={() => <HomePage title={this.state.home.title} subTitle={this.state.home.subTitle} text={this.state.home.text} />} className="container-full" />
                <Route path="/about" render={() => <AboutPage title={this.state.about.title} subTitle={this.state.about.subTitle} text={this.state.about.text} />} />
                <Route path="/services" render={() => <ServicesPage title={this.state.services.title} />} />
                <Route path="/contact" render={() => <ContactPage title={this.state.contact.title} />} />
                <Route path="/galleries" render={() => <GalleriesPage title={this.state.galleries.title} />} />
                <Footer />
            </div>

【问题讨论】:

  • 您可以创建它的 sn-p 或将其托管在 heroku 上,以便我们解决您的问题
  • 好的,让我知道并尝试 sn-p 和 Heroku 以及如何使用它,因为我是这方面的新手
  • 你可以在youtube上搜索,如何将我的项目上传到heroku
  • youtube.com/watch?v=aUW5GAFhu6s&t=21s...........---from this...这是错误来了............当我尝试......“应用程序错误应用程序发生错误并且无法提供您的页面。如果您是应用程序所有者,请检查您的日志以获取详细信息。您可以在 Heroku CLI 中使用命令 heroku logs --tail" whatup no 执行此操作。 8553741736
  • 查看 Heroku 日志,执行失败,比如你的 .env 文件数据

标签: css reactjs bootstrap-4 frontend react-bootstrap


【解决方案1】:

这是z-index的问题,你可以用CSS轻松管理它。只需在您的类上添加下面的 CSS 属性,您的问题就会得到解决,记住我添加了 background-color,因为它显示,除了滑块都从粘性菜单中进入。

.mycontainer{
    z-index: 100;
    background-color: skyblue;
}

.slider-main {
    z-index: 101;
}

【讨论】:

  • 谢谢:是的,它正在工作。现在只有滑块给出了问题。如果您有任何解决方案,请告诉我。因为还卡在这个滑块里
  • 嗨,沙阿。它现在也在工作 - 滑块,希望由于浏览器捕获。谢谢兄弟
  • 很高兴为您提供帮助
  • 你能帮我检查一下吗stackoverflow.com/questions/61491994/…
猜你喜欢
  • 2014-02-09
  • 1970-01-01
  • 1970-01-01
  • 2014-08-01
  • 2023-02-07
  • 2018-05-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多