如何删除我网站侧面的白色 space

How to remove white space on the side of my website

我有一个网站 (https://olsenspkg.com),每个页面的右侧都有白色 space。目前我已经试过这个来解决它:

body {
  overflow-x: hidden !important;
  width: 100%;
}

不过它只在 chrome 上修复了它。 Safari 仍然像我没有输入代码一样。

Regular Site View

White Space on the Right

该元素溢出:

<div id="searchBar">

宽度与parentsdiv相同。将宽度更改为 300px 或完全更改该渲染。

Overflown div

问题出在您 header 的 #searchBar 上。 你给了它 left:478px 但它有 position:relative。所以它仍然占据space。通过向左 478px 使您的网站向右放大 478 像素。

所以删除它并使用其他解决方案定位它。像一个简单的 #searchBar { text-align:right } 我想就可以了。

同时尽量避免在 body 上使用 overflow-x: hidden。你永远不知道你可能会导致什么问题。总是在这种情况下尝试找到导致这种不需要的溢出的元素并处理该特定元素。