调整移动设备元素的大小

发布于 2025-01-19 23:06:23 字数 894 浏览 3 评论 0原文

我知道这可能是一个非常常见的问题,但对于 HTML、CSS、JS 来说还是个新手。我真的想要一个直接的答案,所以如果这是重复的,我很抱歉。

我目前正在开发一个 wordle 克隆,但在调整移动设备的大小方面遇到了问题。在我的电脑上,尺寸看起来很完美。然而,当我在手机上访问它时,底部的键盘似乎非常小。

如果我能得到一些帮助来解决这个问题,那就太好了!谢谢!

这是我的相关 HTML 代码:

<meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale =1, user-scalable=no">

这是我所有相关的 CSS 代码:

.keyboard-row {
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
}

.key-tile {
    /* Box */
    border: 1px solid lightgray;
    width: 5%;
    height: 40px;
    margin: 1px;

    /* Text */
    font-size: auto;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
}

移动版本如下所示:

I know this is probably a very common question, but being new to HTML, CSS, JS. I really wanted a direct answer, so I'm sorry if this is a duplicate.

I'm currently working on a wordle clone and I'm having trouble with the sizing for the mobile devices. On my computer, the sizing looks perfect. However, when I access it on my phone the keyboard at the bottom seems to be really small.

If I could get some assistance with fixing this issue that would be great! Thanks!

Here is my relevant HTML code:

<meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale =1, user-scalable=no">

Here is all my relevant CSS code:

.keyboard-row {
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
}

.key-tile {
    /* Box */
    border: 1px solid lightgray;
    width: 5%;
    height: 40px;
    margin: 1px;

    /* Text */
    font-size: auto;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
}

The mobile verson looks like this:
Wordle clone on mobile

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉态萌生 2025-01-26 23:06:23

尝试在CSS中使用 rem 单元,而不是像素(PX),同时造型键和文本作为REM和EM有助于相对于您的父容器进行调整,并有助于制作这些项目重新负责。
或者,您也可以利用媒体查询来解决您的问题。
希望这可能有助于解决您的问题。

Try using rem unit instead of pixels(px) in your css while styling your keys and text as the rem and em helps to adjust relative to your parent container and helps to make the items reponsive.
or you can also make use of media queries to fix your problem.
Hope that this might help to fix your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文