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


New Jersey
HOME ยป 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


Related to : How do negative margins in CSS work and why is (margin-top:-5 != margin-bottom:5)?
How do negative margins in CSS work and why is (margin-top:-5 != margin-bottom:5)?
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

Why does margin-top work, but margin-bottom doesn't?
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 again using trial and error. A much better solution would to tell if to always be 5px away from the bottom instead of telling it to be X pixels from the top.


Why doesn't this work though?


<body>
<div id="header">
<img src="../../Content/images/cumaviLogo.png" alt="Cumavi.com - Compras y ventas online
Weird Margin Issue in All Versions of IE (Including 9) - Negative Margins?
Web Design

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).
Negative bottom margin not working in IE
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 and Safari. Overflow:hidden is not working for some reason in IE9 and I cannot get the div to close in IE9 by clicking on the close button (mediaclose).*


I use jquery animate to show the div, which is accessed when clicking on a link:


$("#media").click(function () {
$("#mediadetails").animate({height: "425px"}, 1000);



HD Wallpapers
3D
3D Abstract
City
Celebrities
Indian Celebrities
Cars
Travel
Girls
Animals Birds
Movies
Sports
Black White
Nature
Planes
Anime
Food Drink
Dreamy Fantasy
Architecture
Games
Space
Holidays
Flowers
Love
Artistic
Baby
Beach
Bikes Motorcycles
Macro
Computers
Vector
Funny
Army
Textures
Brands
Misc
Music
Other
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .