When I look at the sizes of the divs in Firefox, the cell outputs are 127.5px high, but Observable expects them to be 128px (I’m reading this from the padding-top attribute of the div containing the corresponding source editor). In Chrome, the cell heights are 127px and Observable is making the padding-top of the source editor cells 127px so everything looks fine.
If I manually set the height of the outermost div to an integer then everything is aligned, but then I’d have to calculate the height of these divs, right? Is there an easier solution?
The problem also goes away if I set the header text to an empty string (more generally, if I have an even number of lines in the header), but I’d rather not have to fiddle with things that way.
(There’s an older thread with a similar issue, but the cause there was apparently some custom user styles.)
The good news: For the above CodeMirror example (and the draft notebook it’s based on), the following hack seems to work:
setTimeout(() => {
editor.setSize('100%', '100');
editor.refresh();
div.style.height = div.clientHeight + 'px'; /* added this line */
}, 0);
Setting the height of that div manually like this seems to work because clientHeight is rounded to an integer. Also, this doesn’t cost much since I already had the setTimeout call.
The bad news: It turns out even the built-in md function often generates HTML elements with non-integer px heights:
Thanks for the bump. I have a hunch on how we can fix this. I’ve filed a new issue on our internal tracker and I’ll see if we can make some progress soon.