- -webkit-margin-top-collapse property
- Possible values:
- Example HTML code 1:
- What is the difference of margin-top and -webkit-margin-before
- What is the difference of margin-top and -webkit-margin-before
- Why is -webkit-margin-before (and after, start, end) not being overridden by my explicit margin and padding rule?
- Different margin for webkit browsers
- Margin and width issue in Google Chrome
- margin-top
- Try it
- Syntax
- Values
- Formal definition
- Formal syntax
- Examples
- Setting positive and negative top margins
- Specifications
- Browser compatibility
- See also
- Found a content problem with this page?
- MDN
- Support
- Our communities
- Developers
-webkit-margin-top-collapse property
Possible values:
Default. Vertical margins are collapsed with the adjacent elements. |
Discards the margin. |
Takes the value of this property from the computed style of the parent element. |
Default. Separate margins are drawn for the adjacent elements. |
Example HTML code 1:
head> style> .collMargin -webkit-margin-bottom-collapse: separate; -webkit-margin-top-collapse: separate; margin:20px; > style> head> body> div class="collMargin" style="border:3px solid #000000;"> The margins are separate div> div class="collMargin" style="border:3px solid #000000;"> between these two divisions div> div style="border:3px solid #000000;margin:20px;"> The margins are collapsed div> div style="border:3px solid #000000;margin:20px;"> between these two divisions div> body>
What is the difference of margin-top and -webkit-margin-before
BUT this refers mostly to text margin and it’s depending on the writing-mode,direction and text-orientation, as you can see here margin dev moz or you can search SO for similar questions Your code seems to work ( see snippet below ). my CSS is as follows : — any suggestions, also it is not working in this if i declare margin . screen shots as follows :- for chrome for Firefox Thanks in advance.
What is the difference of margin-top and -webkit-margin-before
Webkit have added its own specific margins which are:
-webkit-margin-before: -webkit-margin-after: -webkit-margin-start: -webkit-margin-end:
I understand the difference of (margin-left and -webkit-margin-start) or (margin-right and -webkit-margin-end) which is related to «left to right» or «right to left» languages.
My question is what is the difference between (margin-top and -webkit-margin-before) or (margin-bottom and -webkit-margin-after) ?
Note: It is obvious that -webkit prefix only works on webkit engine browsers such as chrome and safari. This question is not related to it.
The best answer I could find so far is -web-margin-before acts same as margin-top on normal documents but it will act as margin-bottom on «bottom to top» languages (same idea applies to -webkit-margin-after ).
You can find a number of «bottom to top» languages in this link omniglot.com/writing/direction.htm (thanks to @MarkPlewis)
While Chrome and WebKit supports all the properties and keywords from -webkit-, Safari only supports start (Mozilla does a bit better as it supports both start and end). All these properties are said to work in Safari 6 though; so when that ships, we will need to replace top, right and bottom values with the prefixed properties to make our styling “direction” agnostic.
Basically -webkit- can be used to target different browsers like Safari, Chrome and Firefox. Detail article can be found here.
This article discusses the creation of a base styles sheet for WebKit-based browsers.
To prevent from not applying -webkit- values I use:
Styling input range for webkit with pure CSS, Yes using JS we have a multiple way. simplest one is calling $ (‘input:range’).css (‘background’, ‘linear-gradient (to right, red, #005555 ‘ +val + ‘%, …
Why is -webkit-margin-before (and after, start, end) not being overridden by my explicit margin and padding rule?
I inspect element in chrome, and my rules are applied, but also the following from the user agent stylesheet:
I thought these should be overridden. my rules are not overridden either (not crossed out)
How should I override them?
The rule specified by the user gets applied, and webkit renders margin according to it, «overriding» the default -webkit ones in some way.
The space that I was seeing was from the img not being displayed as block, see this for more about it.
Html — how to make tag and tag inside a inline, By setting the padding and margin of your
and tags, you will be sure that they will not use the inherited and default values. After that, you can …
Different margin for webkit browsers
There is difference between webkit and the other browsers in one absolute positioned element margin.
So how to set another margin for the webkit browsers in the css?
Thanks!
Sometimes these problems can be avoided with experience by structuring your surrounding markup and CSS differently, but if that doesn’t work or isn’t possible in this instance you can use the following CSS hack:
/* CSS properties for all browsers */ #yourObject < position: absolute; left: XXXpx; top: YYYpx; >/* CSS overrides for webkit browsers: Safari 3+, Chrome 1+ */ @media screen and (-webkit-min-device-pixel-ratio:0) < #yourObject < left: LLLpx; top: TTTpx; >>
Webkit CSS Reset?, -webkit-margin-before: 1em; -webkit-margin-after: 1em; -webkit-margin-start: 0px; -webkit-margin-end: 0px; -webkit-padding-start: 40px; I’m …
Margin and width issue in Google Chrome
I am setting my div’s margin and width , all margin and width are showing properly in Firefox and Internet Explorer. However, Google Chrome it’s not working. If I INSPECT the page in Chrome and adjusting my margin , then it shows effect but if I update my CSS then it does not work.
I am also using -webkit-margin-start: 44px; but nothing is working .
any suggestions, also it is not working in this @media screen and (-webkit-min-device-pixel-ratio:0) < if i declare margin .
screen shots as follows :- for chrome
for Firefox
chrome version : 62.0.3202.62
As i said in my comment, you use margin:44px auto which means margin-top:44px margin-right:auto margin-bottom:44px margin-left:auto . But -webkit-margin-start:44px is refering to margin-left
margin-top is -webkit-margin-before . BUT this refers mostly to text margin and it’s depending on the writing-mode,direction and text-orientation, as you can see here margin dev moz or you can search SO for similar questions
Your code seems to work ( see snippet below ). The only problem i see there is that you use position and margin. ( top,left + margin ) . I suggest you either use position either margin. For example, don’t use top:7px but instead use margin:51px auto 44px ( if you want to keep the bottom margin as 44px ).
Without anymore code from you, there is nothing else we can do. If the problem persists, please add a working snippet that replicates your problem
I changed in the code below the webkit-margin-start with webkit-margin-before as explained before
What is the difference of margin-top and -webkit-margin, The best answer I could find so far is -web-margin-before acts same as margin-top on normal documents but it will act as margin-bottom on «bottom to top» languages (same idea applies to -webkit-margin-after ). You can find a number of «bottom to top» languages in this link omniglot.com/writing/direction.htm (thanks to @MarkPlewis) Share
margin-top
The margin-top CSS property sets the margin area on the top of an element. A positive value places it farther from its neighbors, while a negative value places it closer.
Try it
This property has no effect on non-replaced inline elements, such as or .
Syntax
/* values */ margin-top: 10px; /* An absolute length */ margin-top: 1em; /* relative to the text size */ margin-top: 5%; /* relative to the nearest block container's width */ /* Keyword values */ margin-top: auto; /* Global values */ margin-top: inherit; margin-top: initial; margin-top: revert; margin-top: revert-layer; margin-top: unset;
The margin-top property is specified as the keyword auto , or a , or a . Its value can be positive, zero, or negative.
Values
The size of the margin as a fixed value.
The size of the margin as a percentage, relative to the inline size (width in a horizontal language, defined by writing-mode ) of the containing block.
The browser selects a suitable value to use. See margin .
Formal definition
Initial value | 0 |
---|---|
Applies to | all elements, except elements with table display types other than table-caption , table and inline-table . It also applies to ::first-letter and ::first-line . |
Inherited | no |
Percentages | refer to the width of the containing block |
Computed value | the percentage as specified or the absolute length |
Animation type | a length |
Formal syntax
Examples
Setting positive and negative top margins
.content margin-top: 5%; > .sidebox margin-top: 10px; > .logo margin-top: -5px; > #footer margin-top: 1em; >
Specifications
Browser compatibility
BCD tables only load in the browser
See also
- margin-right , margin-bottom , and margin-left and the margin shorthand
- The mapped logical properties: margin-block-start , margin-block-end , margin-inline-start , and margin-inline-end and the shorthands margin-block and margin-inline
Found a content problem with this page?
This page was last modified on Jul 18, 2023 by MDN contributors.
Your blueprint for a better internet.
MDN
Support
Our communities
Developers
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998– 2023 by individual mozilla.org contributors. Content available under a Creative Commons license.