how to adjust css margin top? -


i have div on website , trying position div in css using margin-top property.

i'm using:

margin-top: -0.5px; 

my div ever low when doing if margin-top: -0.6px; high , im trying find value in between 0.5 , 0.6,

is there way can use 2 decimal place values like:

 margin-top: -0.5.5px;  

would appreciate this, thanks?

the short answer fractional css pixel ratios either rounded or truncated.

conisder following:

div.someclass {margin-top: 0.55px;} 

and percentages

div.someclass {margin-top: 35.55%;} 

these values rounded nearest percent browsers, , truncated others. meaning above 2 examples interpreted either 0.6px / 0.5px , 35.6% / 35.5% depending on user's browser.

for more information fractional css values check out stackoverflow thread: are decimal places in css width respected?

how fix this? unfortunately, can't try offset margin fractions adding inner padding fraction offsets margin.

example:

div.outer {margin-top: 0.5px;} div.inner {padding-top: 0.1px;} 

this should result in same output margin-top: 0.6px depending on particulars of overall css theme may notice subtle differences.


Comments