Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centering of elements with odd pixel width / height looks off #773

Closed
pchiusano opened this issue Aug 27, 2014 · 4 comments
Closed

Centering of elements with odd pixel width / height looks off #773

pchiusano opened this issue Aug 27, 2014 · 4 comments

Comments

@pchiusano
Copy link

http://share-elm.com/sprout/53fe3a0ee4b0d19703e96be3

I expect this code to generate a white square with a 1 pixel black border, as I'm adding an extra two pixels to the width and height and placing a white spacer in the center:

import Window

main =
  let inner = color white (spacer 30 30)
      bordered = container (widthOf inner + 2) (heightOf inner + 2) middle inner
              |> color black
      layout (w,h) = container w h middle bordered
  in layout <~ Window.dimensions

Instead, I get, on Chrome:

screen shot 2014-08-27 at 4 06 32 pm

This is latest Chrome build 36.0.1985.143. This is a Macbook Air with a non-retina display. Specs.

On Safari, there seems to be a similar issue, but it's not noticeable unless I zoom in:

screen shot 2014-08-27 at 4 16 36 pm

And in Firefox, it looks like what I expect, even on zoom:

screen shot 2014-08-27 at 4 15 59 pm

@pchiusano
Copy link
Author

Nevermind, I'm closing this. Turns out I had my browser zoomed in to 110%, which I'm guessing was generating some pixel rounding error!

@pchiusano
Copy link
Author

I am reopening this, as it still is generating problems for me, when the element I am adding an outline to is an odd number of pixels. See this test, which adds borders to square spacers of sizes [20..30]:

http://share-elm.com/sprout/53ffaf8de4b0d19703e96cf6

I actually could not figure out an obvious way of adding a 1 pixel border to an element whose width and/or height is an odd number of pixels, even after trying various hacks. :(

@pchiusano pchiusano reopened this Aug 28, 2014
@pchiusano pchiusano changed the title Centering not quite centered on OS X 10.9.3 in Chrome and Safari Centering of elements with odd pixel width / height looks off Aug 28, 2014
@Apanatshka
Copy link
Contributor

from the mailing list discussion:

I think this is a bug that's been around for a while. I remember the workaround: http://share-elm.com/sprout/54003315e4b0d19703e96d25
The cause of the bug is in the CSS transform being used on the inner div. It should apparently be rounded up, not down.

I think the bug and workaround was originally found by Eugen (7gui project).

@evancz
Copy link
Member

evancz commented Aug 6, 2015

Not sure if this is still relevant, but I am trying to make all the issues here directly about elm-compiler. If you can reproduce this please open an issue or PR on elm-lang/core

Mentioning elm-lang/core#332 so folks can find this more easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants