最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

css - Pixel distortion when rendering 1px squares on mobile (React) - Stack Overflow

programmeradmin1浏览0评论

I'm working on a project using React where I render individual pixels as elements (or in some cases). However, on mobile devices, some pixels appear distorted—they stretch into rectangles rather than staying as perfect squares.

Here’s a simplified snippet of how I render each pixel:

<div
    style={{
        position: "absolute",
        top: pixelPosition.y * PIXEL_SIZE,
        left: pixelPosition.x * PIXEL_SIZE,
        width: `${PIXEL_SIZE}px`,
        height: `${PIXEL_SIZE}px`,
        backgroundColor: `${selectedColor}`,
        boxSizing: "border-box",
        pointerEvents: "none",
        imageRendering: "pixelated"
    }}
/>

Even though PIXEL_SIZE is set to 1px, some pixels appear stretched on certain mobile screens.

I’ve attached an image showing the issue.

Desktop Mobile
发布评论

评论列表(0)

  1. 暂无评论