移动 Safari 文本输入宽度错误?
看看这些屏幕截图:
https://i.sstatic.net/1TFuj.png
< a href="https://i.sstatic.net/3fukT.png" rel="noreferrer">https://i.sstatic.net/3fukT.png
我在渲染文本输入时遇到问题当设置为时如预期'宽度:100%'。文本框向右延伸得太远,超出了第一个屏幕截图中的右内边距,并超出了第二个屏幕截图中 div 的右边距。
这是移动 Safari 中的错误吗?如果是这样,有人可以建议解决方法吗?它似乎在其他移动浏览器和桌面版 Safari 中运行良好。该问题似乎仅限于输入元素,因为当以完全相同的方式设置样式时,选择元素似乎具有正确的宽度。
预先感谢您的任何帮助!
这是第一个屏幕截图的代码:
<div style="padding-left: 1em; padding-right: 1em;">
<div style="font-size: 1.2em;">
Username:
</div>
<div>
<input type="text" style="width: 100%; font-size: 1.1em;" id="tbUsername" name="tbUsername">
</div>
</div>
这是第二个屏幕截图的代码(注意样式完全相同的选择元素如何不受影响):
<div class="item">
<hr />
<div class="title">Group Name</div>
<div class="content">
<asp:TextBox ID="tbGroupName" runat="server">
</asp:TextBox>
</div>
<div class="confirmation">
<img alt="" src="../Graphics/Check-icon.png" runat="server" id="imgConfirmGroupName"/>
</div>
<hr />
</div>
这是 CSS:
.item
{
padding-top: .5em;
padding-bottom: .5em;
border-left: 1px solid black;
border-bottom: 1px solid black;
padding-left: 0.5em;
.item.title
{
浮动:向左;
宽度:25%;
}
.item .内容
{
浮动:向左;
宽度:67%;
}
.item .确认
{
浮动:左;
宽度:8%;
}
.item .确认 img
{
左内边距:.3em;
高度:1.1em;
} .
项目小时
{
明确:两者;
可见性:隐藏;
填充:0;
保证金:0;
} .
项目选择
{
宽度:100%!重要;
字体大小:0.9em;
.item
输入
{
宽度:100%!重要;
字体大小:0.9em;
}
Take a look at these screenshots:
https://i.sstatic.net/1TFuj.png
https://i.sstatic.net/3fukT.png
I am having trouble getting text inputs to render as expected when set to 'width: 100%'. The text box extends too far to the right, past the right padding in the first screenshot and past the right margin of the div in the second screenshot.
Is this a bug in mobile Safari? If so, can anyone suggest a workaround? It seems to work fine in other mobile browsers and also in the desktop version of Safari. The problem seems limited to input elements, as select elements seem to have the proper width when styled in the exact same way.
Thanks in advance for any help!
Here's the code for the first screenshot:
<div style="padding-left: 1em; padding-right: 1em;">
<div style="font-size: 1.2em;">
Username:
</div>
<div>
<input type="text" style="width: 100%; font-size: 1.1em;" id="tbUsername" name="tbUsername">
</div>
</div>
And here's the code for the second (notice how the select elements, which are styled the exact same way, are unafflicted):
<div class="item">
<hr />
<div class="title">Group Name</div>
<div class="content">
<asp:TextBox ID="tbGroupName" runat="server">
</asp:TextBox>
</div>
<div class="confirmation">
<img alt="" src="../Graphics/Check-icon.png" runat="server" id="imgConfirmGroupName"/>
</div>
<hr />
</div>
And here's the CSS:
.item
{
padding-top: .5em;
padding-bottom: .5em;
border-left: 1px solid black;
border-bottom: 1px solid black;
padding-left: 0.5em;
}
.item .title
{
float: left;
width: 25%;
}
.item .content
{
float: left;
width: 67%;
}
.item .confirmation
{
float:left;
width: 8%;
}
.item .confirmation img
{
padding-left: .3em;
height: 1.1em;
}
.item hr
{
clear: both;
visibility: hidden;
padding: 0;
margin: 0;
}
.item select
{
width: 100% !important;
font-size: 0.9em;
}
.item input
{
width: 100% !important;
font-size: 0.9em;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许输入上的这个属性会对您有所帮助?
Maybe this property on inputs will help you?