css - 如何在带有上下文的 Google 登录 (GSI) 按钮上设置响应宽度
问题描述
我从https://developers.google.com/identity/gsi/web/guides/personalized-button添加了使用 Google 登录按钮
此上下文添加width
到 iframe 内的元素样式。我知道按照规范,Google 按钮应该在 40-400px 范围内。我想制作页面容器max-width: 400px
,但这个按钮根本不能与容器一起缩放。
我是否必须使用 JavaScript 来更新data-width
属性,或者是否有使用 CSS 的正常解决方案?
<div class="g_id_signin" data-width="400" />
解决方案
哈克
我使用data-width="328"
并匹配了容器max-width: 328px
带内边距的 328 像素可以适应 360 像素的手机屏幕(Moto G4、iPhone 6)。
<script src="https://cdn.tailwindcss.com"></script>
...
<div class="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
<div class="w-full space-y-8" style="max-width: 328px">
<div class="flex flex-col gap-2">
<div
id="g_id_onload"
class="w-full"
style="display: none"
:data-client_id="clientID"
data-callback="handleGoogleCallback"
data-auto_prompt="false"
data-auto_select="true"
/>
<div
class="g_id_signin w-full"
data-type="standard"
data-size="large"
data-theme="outline"
data-shape="rectangular"
data-text="continue_with"
data-logo_alignment="center"
data-width="328"
/>
</div>
</div>
</div>
适当的解决方案
等待谷歌更新他们的图书馆。不要指望它会很快发生。
推荐阅读
- c# - 发出 Http GET 请求时出现 OutOfMemoryException
- reactjs - Google 字体不适用于在 Github Pages 上部署的 React 应用程序
- html - CSS样式不呈现
- azure - AKS 使用 Terraform - 安装 hashcorp/azurerm v2.70.0 时出错:意外 EOF
- python - 从python中的另一个函数打印在构造函数中实例化的列表中的元素
- python - 用户的个人资料未创建
- webhooks - 如何在 Cloudflare bot-fight-mode 中允许 Razorpay Webhook?
- javascript - JS:如何在单击事件处理程序中将用户输入添加到对象实例的静态数组
- node.js - 将遥测数据从设备发送到 IoT 中心的合适 NodeJS 代码是什么?
- sql - 选择表中所有列的最简单方法,在一列上具有不同的条件