IE8中输入的CSS样式问题

发布于 2024-10-21 12:40:37 字数 1182 浏览 9 评论 0原文

我在使输入中的文本在 Internet Explorer 8 中正确显示时遇到问题。 Firefox、Safari 和 Chrome 都显示相同的内容。

Firefox、Safari 和 Chrome

Firefox、Safari 和 Chrome

Internet Explorer 8

Internet Explorer 8

    <form action="" method="get">
       <input id="q" name="q" type="text">
       <input id="s" name="s" type="submit" value="Sök">
    </form>

#q {
    background:url(../../image_layout/search_field.png) no-repeat;
    width:209px;
    height:32px;
    padding:0 5px 0 5px;
    text-align:left;
    margin:0;
    border:0;
    font-family:Arial, Helvetica, sans-serif;
    font-size:14px;
    font-weight:bold;
    color:#09305b;
    font-weight:bold;
    position:absolute;
    left: 0px;
    top: 19px;
}
#s {
    background:url(../../image_layout/serach_buttom.png) no-repeat;
    width:56px;
    height:34px;
    padding:0;
    margin:0;
    color:#FFFFFF;
    font-family:Arial, Helvetica, sans-serif;
    font-size:14px;
    font-weight:bold;
    border:0;
    position:absolute;
    left: 225px;
    top: 17px;
}

I have a problem getting the text in an input to show correct in Internet Explorer 8.
Firefox, Safari and Chrome all show the same.

Firefox, Safari and Chrome

Firefox, Safari and Chrome

Internet Explorer 8

Internet Explorer 8

    <form action="" method="get">
       <input id="q" name="q" type="text">
       <input id="s" name="s" type="submit" value="Sök">
    </form>

#q {
    background:url(../../image_layout/search_field.png) no-repeat;
    width:209px;
    height:32px;
    padding:0 5px 0 5px;
    text-align:left;
    margin:0;
    border:0;
    font-family:Arial, Helvetica, sans-serif;
    font-size:14px;
    font-weight:bold;
    color:#09305b;
    font-weight:bold;
    position:absolute;
    left: 0px;
    top: 19px;
}
#s {
    background:url(../../image_layout/serach_buttom.png) no-repeat;
    width:56px;
    height:34px;
    padding:0;
    margin:0;
    color:#FFFFFF;
    font-family:Arial, Helvetica, sans-serif;
    font-size:14px;
    font-weight:bold;
    border:0;
    position:absolute;
    left: 225px;
    top: 17px;
}

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

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

发布评论

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

评论(9

场罚期间 2024-10-28 12:40:37

尝试指定 line-height: 34px 或类似值。

Try specifying a line-height: 34px or thereabouts.

紫轩蝶泪 2024-10-28 12:40:37

有一个 CSS3 规则:盒子大小。 IE8支持该规则。

IE(包括IE8)具有非标准盒子模型,其中paddingborder包含在widthheight 而其他浏览器则采用标准,并且不将 padding 和 border 添加到 width 中。 此处对此进行了详细描述。
通过将 box-sizing 设置为 content-box,您可以告诉浏览器不要将边框和填充包含在宽度中,并且如果您设置 box-sizing: border- box,所有浏览器都会将边框和内边距包含在宽度中。这样或那样,所有现代浏览器的显示将是一致的(并不是说 IE8 如此现代,但它也支持这个规则:)。

There is a CSS3 rule: the box-sizing. This rule is supported by IE8.

The IEs(including IE8) have non-standard box model, where padding and border are included into width and height whereas other browsers go with standard and don't include padding and border into width . It is described in detail here.
By setting the box-sizing to content-box you tell the browsers not to include border and padding into width, and if you set box-sizing: border-box, all browsers will include border and padding into width. This or this, the display will be consistent across all modern browsers(not that IE8 is so modern, but it supports this rule too :).

高速公鹿 2024-10-28 12:40:37

我必须设置行高display: inline。不知道为什么,但它对我有用。

I had to set the line-height and display: inline. No idea why, but it worked for me.

不离久伴 2024-10-28 12:40:37

为搜索输入字段设置行高属性#q?

Set a line-height property for search input field #q?

暖树树初阳… 2024-10-28 12:40:37

尝试设置针对 IE8 及更低版本的行高,如下所示:

line-height: 32px\9;

line-height 值应等于输入的高度,并且 \9 将针对 IE8 及更低版本。

Try setting a line-height targeting IE8 and below, like this:

line-height: 32px\9;

line-height value should be equal to input's height and \9 will target IE8 and below.

等风来 2024-10-28 12:40:37

输入的位置应为 position:absolute; 才能使 line-height:37px;display:inline; 正常工作。

The position of input should be position:absolute; in order for line-height:37px; and display:inline; to work.

一绘本一梦想 2024-10-28 12:40:37

我对此遇到了很多麻烦,最后我解决了:

例如。你设置

  INPUT {
   line-height: 44px
}

并且...

  INPUT:focus {
    line-height: 45px
 }

这个...f...像素产生了差异(焦点应该比正常多+1px),现在你的光标在IE8中处于正确的位置。

I had much trouble with that, and finally i resolved it:

for ex. you set

  INPUT {
   line-height: 44px
}

and...

  INPUT:focus {
    line-height: 45px
 }

this one...f... pixel makes the difference (focus shoud have +1px more than normal) and now you have your cursor in good position at IE8.

未蓝澄海的烟 2024-10-28 12:40:37

只需使用

line-height: 34px!important;
height: 34px;

Just use

line-height: 34px!important;
height: 34px;
谈下烟灰 2024-10-28 12:40:37

我还不能发表评论,马修的回答对我有用,但如果人们想要一个仅 IE 的包装器而不在其他地方搜索:

@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    line-height: 20px;
}

I can't comment yet, Matthew's answer worked for me, but in case people wanted an IE-only wrapper without searching anywhere else:

@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    line-height: 20px;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文