edwardtufte / tufte-css

Style your webpage like Edward Tufte’s handouts.
https://edwardtufte.github.io/tufte-css/
MIT License
5.96k stars 458 forks source link

Links not underlined when zoomed out in Chrome #96

Closed kejadlen closed 5 years ago

kejadlen commented 8 years ago

Just FYI, I browse the web at 90% by default, and the links don't show up in Chrome. They show up at 100+% and seem to work fine in Firefox/Safari, though.

daveliepmann commented 8 years ago

Confirmed—thanks for the report. Strange.

adamschwartz commented 8 years ago

One option is to only apply our custom underline CSS when a browser zoom of 1 is detected:

Detection can be done with something like this:

var getBrowserZoom = function() {
  return window.outerWidth / (document.body.clientWidth + parseInt(getComputedStyle(document.body)['margin-left'], 10) + parseInt(getComputedStyle(document.body)['margin-left'], 10))
};

document.documentElement.setAttribute('data-browser-zoom', getBrowserZoom());

Then these lines would be prefixed with html[data-browser-zoom="1"]:

html[data-browser-zoom="1"] a:link {
  /* ... */
}
daveliepmann commented 8 years ago

As Tufte CSS is a pure-CSS project, a JavaScript solution is not in-scope for this project. I like Adam's JS trick and it's a good answer for this problem in general, but we'll need to find a different answer within the context of "base" Tufte CSS.

Might it be possible to switch all the px declarations within a:link to em? Or would that lead to other problems?

adamschwartz commented 8 years ago

Definitely worth a shot!

paul90 commented 7 years ago

An alternative might be to add to the existing webkit media query, to allow for how webkit does sub-pixel rounding, something like:

@media screen and (-webkit-min-device-pixel-ratio: 0) { a:link { background-size: 0.05em 1px, 0.05em 1px, 2px 1.5px; background-position-y: 87%, 87%, 87%; } }

Or to use to top in the linear-gradient, something like:

a:link { background: linear-gradient(to top, transparent 1px, #333 1px, transparent 2px);
...}

and remove all the other background-* properties. Though this will also likely need to go into a media query so that the stops can be tailored for the different browser behaviours.

juliuso commented 5 years ago

Likely an old Chrome bug that was fixed in previous releases. Links work fine at 90% on Chrome 74.0.3729.131. Issue should be safe to close.

Screen Shot 2019-05-13 at 5 34 33 PM
daveliepmann commented 5 years ago

Thanks for the report! I was able to replicate the OK behavior so closing.