简体   繁体   English

如何删除我网站一侧的空白区域

[英]How to remove white space on the side of my website

I have a website ( https://olsenspkg.com ) that has white space on the right hand side of every page.我有一个网站 ( https://olsenspkg.com ),每个页面的右侧都有空白区域。 Currently I have tried this to solve it:目前我已经尝试过这个来解决它:

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

It only fixes it on chrome though.不过,它只能在 chrome 上修复它。 Safari still acts like I haven't put that code in. Safari 仍然表现得好像我没有把代码放进去。

Regular Site View常规站点视图

White Space on the Right右侧的空白区域

This element is overflown:此元素溢出:

<div id="searchBar">

The width is the same as parents div.宽度与父 div 相同。 Change width to 300px or change that rendering completely.将宽度更改为 300px 或完全更改渲染。

Overflown div溢出 div

The problem is with the #searchBar from your header.问题出在标题中的#searchBar You gave it left:478px but it has position:relative.你给了它left:478px但它有 position:relative。 So it still occupies space.所以它仍然占据空间。 By giving it left 478px it made your website 478px larger to the right.通过给它左边478px它使您的网站向右大 478 像素。

So remove that and position it using other solutions.所以删除它并使用其他解决方案定位它。 Like a simple #searchBar { text-align:right } i guess will do the trick.就像一个简单的#searchBar { text-align:right }我想可以解决问题。

Also try to avoid using overflow-x: hidden on body .还要尽量避免使用overflow-x: hidden on body You never know what problems you might cause.你永远不知道你可能会导致什么问题。 Always in this scenarios try to find the element that is causing this unwanted overflow and deal with that specific element.总是在这种情况下尝试找到导致此不需要的溢出的元素并处理该特定元素。

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

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