jeffreyveon
jeffreyveon

Reputation: 13810

HTML/CSS: Making width consistent across multiple resolutions

I have some squares s of size 15px rendered on a page. Their absolute size varies based on the screen resolution - so on very large resolutions, these end up looking much smaller than I want them to be.

How do I define the width in CSS to make sure they are more or less proportionate across all the different resolutions?

Upvotes: 1

Views: 1447

Answers (2)

Piotr Rochala
Piotr Rochala

Reputation: 7781

Read about CSS Units. You need to use relative unit, such as: em or ex. Percentage is always a good way to go, but sometimes it’s hard to 'bind it' to the font size.

Upvotes: 0

Vincent Ramdhanie
Vincent Ramdhanie

Reputation: 103135

You can use percentages.

  width:20%

this way the width is a percentage of the screen size regardless of resolution.

Upvotes: 3

Related Questions