Click here to Skip to main content
15,311,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two div elements, and they are both colored in so you can see them on screen. However, I want to recreate this. I want to add another div, but with same amount of pixels between them. I know how to position divs: I don't know how many pixels between the original two elements. How to find the number of pixels there?

What I have tried:

I've tried looking for online pixel grids, but cannot find any.
Updated 13-Jun-20 11:37am

1 solution

It depends on how the HTML / CSS is written, there are many, many different ways to "space out" two divs, and almost none of them specify pixels - because the number available vary according to the hardware the browser is running on.

So counting pixels is probably not a good idea (easy though it is, there are many screen rulers out there, most of them free) - it may work fine on your screen but be wildly out on my machines for example.

I'd look at how the original divs are spaced and start from that - any other approach will almost certainly fail in release.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900