How do negative margins in CSS work and why is (margin-top:-5 != margin-bottom:5)?



Category : Web Design

A common trick for vertical positioning elements is to use the following CSS:


.item {
position:absolute;
top:50%;
margin-top:-8px; /* half of height */
height: 16px;
}

When seen in the metric view as in Chrome this is what you see:



However, there is no visual margin depicted when you hover over the element i.e. the margin is 'outside' the border and can be visualized. But negative margins don't show up. How do they look and what is it that makes it different?


Why is margin-top:-8px not the same as margin-bottom:8


View Replies

Related to : How do negative margins in CSS work and why is (margin-top:-5 != margin-bottom:5)?


Why does margin-top work, but margin-bottom doesn't?
Category : Web Design

I have the following HTML markup and I want the menu div tag to always be 5px away from the bottom border of the parent container.


I can manually through trial and error position it using margin-top, but if I were to change the logo or modify the div size I'd have to change this value


View Replies


Weird Margin Issue in All Versions of IE (Including 9) - Negative Margins?
Category : Development
http://www.goo.gl/tpL04
You can see the difference here:
http://img534.imageshack.us/img534/8...20813at557.png
Any ideas? A negative margin is being used to pull the image "up" - Im thinking that may have something to do with it? The problem only occurs in IE (of course).

View Replies


Negative bottom margin not working in IE
Category : Web Design

I have a div that is hidden from view:


position:fixed;
bottom:-240px;

*UPDATE II *


doubling the bottom from bottom:-240px to -480px and then adjusting the animation height has hidden the div in IE9 and eliminated the flickering in Chrome an


View Replies


Safari Margin Issue - not the negative margin on a floated element bug
Category : Development

Background info:
- I have validated the page and CSS, no problems there
- Site is working properly in Firefox and IE, seems to be a margin issue in Safari
-This margin issue is not the common Safari bug with a negative margin being applied to a floated element
-I am using Safa


View Replies


Safari margin issue - not the float with negative margin bug
Category : Web Design

Background info:
- I have validated the page and CSS, no problems there
- Site is working properly in Firefox and IE, seems to be a margin issue in Safari
-This margin issue is not the common Safari bug with a negative margin being applied to a floated element
-I am us

View Replies


swf at 100% width/height with a left margin of 400px and a bottom margin of 200px?
Category : Webmasters
Please can someone tell me if it is possible to have a swf at 100% width/height with a left margin of 400px and a bottom margin of 200px? Have managed the left margin using:
<div style="height:100%;margin-left:400px;"> <div id="flashcontent"></div> </div

View Replies


How can I make the bottom margin of a div equal to its percentage-calculated right margin?
Category : Programming Languages

I have an array of floating divs that fit 4 to a row. Their widths and right margins add up to 100%. Their bottom margins, however, are static. CSS below:


.item {
position: relative;
float: left;
height: 200px;
width: 23%;
margin-right:

View Replies


Height of div under div with negative margin not reaching bottom window edge
Category : Development
I suppose the summary pretty much says what my issue is. I would provide a link but this particular page only works if you have login credentials, so I included a screen shot. You can see the location of the footer is way up high but the bottom of it should hug the window. The white content is sp

View Replies


Unwanted red line, margins, bottom page margin, em sizes bad, menu item grouping
Category : Development
I created a simple CSS layout (code and example below) for
bloggin/writing but ran into five issues that I need help with:
1. How do I get rid of the right-margin red line on the last three
right-boxes in Internet Explorer?
2. How can I put a 4px margin BETWEEN the right-boxes, &

View Replies


Will the Screen fit to all devices if i use margin top's and margin bottom's in XML in Android
Category : Android

I am developing an application in which i need to use lot of text-views and i am using a relative layout.Since i positioned my text-views in different coordinates(margintop=20dp),will the layout fit for all the android devices(tabs,Nook color phones,normal devices etc)


Any suggestions


View Replies


2012 / 2017 Copyrights BigHow , All Rights Reserved .