Mobile app version of vmapp.org
Login or Join
Rambettina927

: PSD to HTML&CSS - my margins are wrong I am having trouble with replicating exact margins from the PSD in CSS. Whenever I measure a margin with a select tool I get, for example, 32px. Then

@Rambettina927

Posted in: #AdobePhotoshop #Css #Html #Measurement

I am having trouble with replicating exact margins from the PSD in CSS. Whenever I measure a margin with a select tool I get, for example, 32px. Then I put this in my CSS code:

div {
margin-top:32px;
}


But even though the margin is correctly set (checked with Firebug), the look of that element is still weird, like way off. The margin seems too big, I have to calculate it by eye after setting the PSD to 100% view instead of using those raw numbers.

How can I configure my Photoshop to give me correct measures that I can then apply in CSS so that PSD and CSS margins (and basically all measures) match?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Rambettina927

2 Comments

Sorted by latest first Latest Oldest Best

 

@Jamie315

It's true that image resolution is meaningless on the web. What determines how images are sized is the overall pixel dimensions of the images at whatever screen resolution of the display device.

But for the purposes of judging pixel distance for web design, if you set your image in Photoshop to 72 dpi, it should give you a one-to-one relationship between your image when viewed at 100% in Photoshop, and your browser (at it's default zoom-level) on a desktop computer. Here's an example. I screen-grabbed this page and opened that resulting image in Preview on my Mac (I'd use Photoshop, but my PC's BIOS broke two days ago). I moved the image over so this page would show in the background, and viewed the images' details. Notice the resolution of said screen-grab:



The elements all appear the same size both on the web page in the background, and on the 72dpi image displayed at 100% in Preview.

Mobile devices will display at higher resolutions, so naturally your elements will appear smaller on those screens. But it will be a proportional shift, so the relationship between, say, an image and it's border/padding, will be proportionally equal.

10% popularity Vote Up Vote Down


 

@Shelley591

There isn't necessarily a direct correlation between pixel measurements in Photoshop and how CSS works in the browser. In other words, if you need 32px of space on your page, you may have to go with something like 28px to account for margin or padding on another element.

In general, it's best to design things 'loose' so things can have a few pixels give and take. Pixel perfection in the browser is a bit like tilting at windmills.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme