How to extend header to the full page width? [duplicate]

心不动则不痛 提交于 2020-02-25 15:49:09

问题


How can I extend my header to the full page? I have tried margin-left & right but that doesn't work.

Header.css

    background: green;
    height: 70px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
    left: 0;
    right: 0;
} 


  .header-right {
    float: right;
  }

  @media screen and (max-width: 500px) {
    .header-right {
      float: none;
    }
  }

Here's my app.tsx file:

const Header = () => (
  <div className = 'header'>
  <h1>Instaride</h1>
  <div className="header-right">
    <Button> Sign In</Button>
    <Button> Contact</Button>
  </div>
</div>
);

export default Header;


回答1:


Looks like there could be a margin for your body element. Try setting:

body{
    margin: 0;
}


来源:https://stackoverflow.com/questions/60020935/how-to-extend-header-to-the-full-page-width

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!