【问题标题】:button element looks small on mobile按钮元素在手机上看起来很小
【发布时间】:2018-12-23 00:31:16
【问题描述】:

我有一个简单的输入和按钮。无论屏幕大小如何,该按钮在实际计算机上看起来都很好。第一个屏幕截图是从开发工具的移动视图中看到的。然而,当我真正用手机访问该网站时,我得到了第二张照片。如您所见,该按钮比桌面设置上的要短。关于如何解决这个问题的任何想法?

what it looks like on desktop and should look like on mobile

What it actually looks like on mobile

.input-field {
  width: 370px;
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
  border-top-right-radius: 0px;
  border-bottom-right-radius: 0px;
  height: 35px;
  outline: none;
  border: none;
  font-size: 16px;
  @media (max-width: 500px) {
      width: 250px;
  }

}
.email-input {
  display: flex;
  height: 35px;
  justify-content: center;
  align-items: center;
  margin-top: 60px;

}
.email-button {
  height: 37px;
  border-top-left-radius: 0px;
  border-bottom-left-radius: 0px;
  background-color: #50AE54;
  color: white;
  font-size: 16px;
  width: 100px;
  border: none;
  outline: none;
  @media (max-width: 600px) {
      width: 75px;
  }
<div class="email-input">
     <input type="text" class="input-field" [(ngModel)]="email_address" placeholder="Email me for updates" />
     <button class="email-button" (click)="subscribe()">Send</button>
</div>

【问题讨论】:

  • 尝试将box-sizing: border-box; 添加到inputbutton,并将两者的高度都设置为100%
  • 它在 android chrome 上运行良好,但在 safari 或 ios chrome 上运行良好。
  • 很高兴知道@Ammar
  • 我尝试添加 box-sizing 但似乎没有什么不同@user184994

标签: javascript html css angular angular6


【解决方案1】:

我已经在 codepen 中运行了你的代码和样式,它在不同的设备上看起来都是一样的。

如我所见,不仅按钮样式受到影响,其余部分也受到影响:输入框中的文本填充。

也许父样式正在影响此组件的样式?

(如果您使用 Chrome 进行调试,您可以轻松检查元素 - How to inspect CSS element using Chrome?

【讨论】:

  • 如果您只是在使用 chromes 开发工具的计算机上,它在不同设备上看起来都是一样的。但是如果你在实体手机上运行它就行不通了。
【解决方案2】:

您可以使用引导程序轻松创建响应式网页 链接

Bootstrap

check this also

还要检查

https://en.wikipedia.org/wiki/Responsive_web_design

用于响应式网页设计

【讨论】:

  • 你是否在你的 Angular 项目中安装了引导程序
  • 我不使用引导程序
  • 如果你喜欢medium.com/@tomastrajan/…试试这个
【解决方案3】:

添加 *{ box-sizing: border-box } 到 CSS。
这解决了问题。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2018-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多