For example, I have a div that has a height of 100px
(I don't know the height, but let's suppose I did). I want to set the margin-bottom
to a percent, so 25%
would be 25px
assuming the previous height. However, the percent seems to be of the document, not the element:
<div style="height:100px;margin-bottom:100%"></div>
The margin should be 100px
but it isn't, it is 100% of the height of the page.
The element is just a line of text that has no background, so using height:150%
theoretically could also work.
The margin-bottom property is used to specify the width of the bottom area of the element's margin box. That is, it specifies the area of space required at the bottom of the element, outside any defined border. Every element on a web page is rectangular.
Change or set page marginsOn the Page Layout tab, in the Page Setup group, click Margins. Click the margin type that you want. For the most common margin width, click Normal. Note: When you click the margin type that you want, your entire document automatically changes to the margin type that you have selected.
Top and bottom margins do not affect inline elements because inline elements flow with content on the page. You can set left and right margins/padding on an inline element but not top or bottom because it would disrupt the flow of content.
top margin is 10px. right and left margins are 5px. bottom margin is 15px.
How about a CSS3 solution:
div { -webkit-transform: translateY(-50%); -moz-transform: translateY(-50%); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With