简体   繁体   English

带有圆形中心按钮的页脚 UI

[英]Footer UI with Circle center button

I have a problem centering a button on the footer.我在将按钮放在页脚上时遇到问题。 I have two icons on the left and right, I am able to create the UI but it does not look the same(the center icon is a little weird with padding and shadow).我在左侧和右侧有两个图标,我可以创建 UI,但它看起来不一样(中心图标的填充和阴影有点奇怪)。 I am using material-ui .我正在使用material-ui Here's the picture of what I would like to create:这是我想要创建的图片:

页脚模型

Here's the code sandbox URL: https://codesandbox.io/s/footer-mobile-responsive-icvvs?file=/src/App.js这是代码沙箱 URL: https : //codesandbox.io/s/footer-mobile-responsive-icvvs?file=/ src/ App.js

Component code :组件代码:

<AppBar position="fixed" className="footer__app-bar">
    <Toolbar disableGutters className="footer__toolbar">
      <Link href="/">
        <div className="footer__home">
          <img src={HomeIcon} alt="home" />
          <div className="footer__home-title">HOME</div>
        </div>
      </Link>

      <Link href="/book">
        <>
          <div className="footer__book-fab-container">
            <Fab aria-label="book">
              <img src={CalendarIcon} alt="book" />
            </Fab>
          </div>
          <div className="footer__book-title">BOOK</div>
        </>
      </Link>

      <Link href="/profile">
        <div className="footer__profile">
          <img src={ProfileIcon} alt="profile" />
          <div className="footer__profile-title">PROFILE</div>
        </div>
      </Link>
    </Toolbar>
  </AppBar>

Styles:款式:

.footer__app-bar {
background-color: $color-white;
color: $color-black;
top: auto;
bottom: 0;
box-shadow: 0px -5px 23px -5px rgba(0, 0, 0, 0.17);
font-family: AvenirNext;
padding: 0px 35px 0px;
.footer__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  .footer__home {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    img {
      width: 18px;
      height: 19px;
    }
    .footer__home-title {
    }
  }
  .footer__book-fab-container {
    position: absolute;
    z-index: 1;
    top: -28px;
    left: 0;
    right: 0;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border: 10px solid white;
    width: 76px;
    border-radius: 50%;
    box-shadow: 0px -5px 23px -5px rgb(0 0 0 / 17%);
    img {
      position: absolute;
      z-index: 1;
      left: 0;
      right: 0;
      margin: 0 auto;
    }
    .footer__book-title {
    }
  }
  .footer__profile {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    img {
      width: 15px;
      height: 20px;
    }
    .footer__profile-title {
    }
  }
}
}

How can I create the exact same UI?如何创建完全相同的 UI?

I have done some work and tried to achieve above image.我做了一些工作并试图实现上面的图像。 在此处输入图片说明 Can you replace your css and container code from below and check.您可以从下面替换您的 css 和容器代码并检查。
CSS: CSS:

.footer__app-bar {
  // margin: 20px;
  background-color: white;
  color: black;
  top: auto;
  bottom: 0;
  box-shadow: 0px -5px 23px -5px rgba(0, 0, 0, 0.17);
  font-family: AvenirNext;
  padding: 0px 35px 0px;
  height: 80px;
  .footer__toolbar {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .footer__home {
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      img {
        width: 18px;
        height: 19px;
      }
      .footer__home-title {
       
      }
    }
    .footer__book-fab-container-dummy {
      box-shadow: 1px -3px 23px 3px rgb(0 0 0 / 17%);
      height: 26px;
      width: 65px;
      z-index: -8;
      border-top-left-radius: 90px;
      border-top-right-radius: 90px;
      position: absolute;
      top: -47px;
      left: 290px;
      background: transparent;
    }

    .footer__book-fab-container {
      height: 43px;
      width: 84px;
      border-top-left-radius: 90px;
      border-top-right-radius: 90px;

      top: -52px;
      background: WHITE;
      position: absolute;
      .MuiFab-root {
        position: absolute;
        top: 14px;
        left: 14px;
      }
      img {
        position: absolute;
        z-index: 1;
        left: 0;
        right: 0;
        margin: 0 auto;
      }
     
    }

    
  .footer__book-fab-container:before,
    .footer__book-fab-container:after {
        content: "";
        position: absolute;
        height: 10px;
        width: 20px;
        bottom: 0;
    }

    .footer__book-fab-container:after {
        right: -20px;
        border-radius: 0 0 0 10px;
        -moz-border-radius: 0 0 0 10px;
        -webkit-border-radius: 0 0 0 10px;

        -webkit-box-shadow: -10px 0 0 0 #fff;
        box-shadow: -10px 0 0 0 #fff;
    }

    .footer__book-fab-container:before {
        left: -20px;

        border-radius: 0 0 10px 0;
        -moz-border-radius: 0 0 10px 0;
        -webkit-border-radius: 0 0 10px 0;

        -webkit-box-shadow: 10px 0 0 0 #fff;
        box-shadow: 10px 0 0 0 #fff;
  }
  

    .footer__book-title {
      margin: 20px 0 0 20px;
    }
    .footer__profile {
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      img {
        width: 15px;
        height: 20px;
      }
      .footer__profile-title {
      }
    }
  }
}

HTML: HTML:

  <div className="App">
      <AppBar position="fixed" className="footer__app-bar">
        <Toolbar disableGutters className="footer__toolbar">
          <div className="footer__home">
            <img src={HomeIcon} alt="home"/>
            <div className="footer__home-title">HOME</div>
          </div>

          <div>
            <div className="footer__book-fab-container-dummy">
            </div>
            <div className="footer__book-fab-container">
              <Fab aria-label="book">
                <img src={CalendarIcon} alt="book" />
              </Fab>
            </div>
            <div className="footer__book-title">BOOK</div>
          </div>

          <div className="footer__profile">
            <img src={ProfileIcon} alt="profile" />
            <div className="footer__profile-title">PROFILE</div>
          </div>
        </Toolbar>
      </AppBar>
    </div>

Codepen link 代码笔链接

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM