Extra padding on Chrome/Safari/Webkit — any ideas?

隐身守侯 提交于 2019-12-03 05:02:44

Your page has an element near the top with a top-margin that extends outside your page wrapper. If you have this:

<div class="wrapper" style="margin: 0">
  <div class="section" style="margin: 40px 0"> Stuff! </div>
</div>

Then the .section element will be positioned at the top of the .wrapper and its 40px margin will extend out the top. This has to do with the way margins collapse together so that two margins between elements don't accumulate. You can prevent this by adding overflow: hidden on the wrapper.

In your markup, it's the .mini-search element that has a 40px top margin. Either remove this margin, or add overflow: hidden on the fieldset that contains it.

The WebKit styles sheet contains the following: 'margin' and 'padding' properties:

-webkit-margin-before:
-webkit-margin-end:
-webkit-margin-after:
-webkit-margin-start:

-webkit-padding-before:
-webkit-padding-end:
-webkit-padding-after:
-webkit-padding-start:

Enjoy

Horacio Nuñez

Use this css code:

/*Reset Safari User Agent Styles*/
* {-webkit-padding-start: 0px;}

The issue you comment is because the user agent style, I learn about it inspecting the body tag with the browser tool. You should track down the element styles on a navigator using the tools it provides (now all the importants include a DOM inspector) so you can demystify the non-standard behavior.

I know you dont ask for it but talking about WebKit stuffs, i paste a code for getting rounded borders on every browser but IE.

.rounded
{
-moz-border-radius:5px; /*works on Firefox */
-webkit-border-radius:5px; /*works on Safari and Google Chrome*/
border-bottom-radius: 5px; /*works on Opera*/
}

i trust you have done:

body {padding :0; margin:0}

by default the body tag has padding.

Kaja

It is, in my opinion, caused by an EMBED element added by some plugin just after the HTML opening tag* (check "right click > inspect element" to see if it is really there). If yes, there are basically two options to follow:

  1. disable/remove the plugin which is responsible for adding the element; (preferred, as it's global)
  2. insert embed{display:none} into your style sheet.

*This was my case - the plugin called default plugin and both disabling & removing helped solve the issue.

I'm able to fix it by removing the rule:

* { padding: 0 } 

From your CSS. I'm not sure what that's breaking, but that is the cause.

Always include the YUI reset css file.

and: body, html {padding: 0; margin:0} that's it!

This works with IE (at least IE v10 in my tests):

-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;

The bottom one is the one that works for IE 10, just keeps all the dimensions to what you set a selector/element to be in the width and/or height.

I had the same problem with my nav that has a padding and contains buttons. Overflow:hidden did work, but it also cut the buttons off, because they had a padding that crossed the border of the navs height. So I tried overflow:visible and that worked just fine for me.

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