overflow-x:hidden still can scroll

前端 未结 10 837
滥情空心
滥情空心 2020-12-05 16:48

The problem is:

I have a full width bar menu, which is made by creating a big margin on the right and to the left. This margin should be cropped by overflow-x:

10条回答
  •  温柔的废话
    2020-12-05 17:46

    I had this exact same problem. I solved it by putting overflow-x: hidden; on both the body and html.

    html {
      margin: 0 auto;
      padding: 0;
      overflow-x: hidden;
    }
    body {
      margin: 0 auto;
      overflow-x: hidden;
      width: 950px;
    }
    .full {
      background: red;
      color: white;
      margin-right: -3000px !important;
      margin-left: -3000px !important;
      padding-right: 3000px !important;
      padding-left: 3000px !important;
    }
    abc

提交回复
热议问题