html - 火狐 :before ignores positions

标签 html css firefox

我有这个输入,在 :before 标签中定义了一些内容。在 IE 和 Chrome 中它运行完美,但 Firefox 把它弄得一团糟。

内容应该在输入标签中可见,但在 Firefox 中,内容在 input-group-addon 中可见。

我的 HTML:

<div class="col-sm-6">
  <div class="input-group">
     <div class="iban">
        <input type="text" name="iban" class="form-control text-uppercase">
     </div>

     <div class="input-group-addon">
        <span class="glyphicon"></span>
     </div>
  </div>
</div>

我的 CSS:

.iban:before {
  content: 'CH';
  color: #999;
  position:absolute;
  padding-left:7px;
  padding-top:7px;
  z-index:1000;
}

.iban > input {
  padding-left:29px;
}

我用 fiddle 复制了它,我希望有人以前遇到过这个问题并且能够帮助我。

https://jsfiddle.net/9wme1roo/3/

最佳答案

您还没有给伪元素任何位置值

.iban:before {
  content: 'CH';
  left: 0; /* add this */
  color: #999;
  position:absolute;
  padding-left:7px;
  padding-top:7px;
  z-index:1000;
}

JSFiddle Demo

关于html - 火狐 :before ignores positions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34433297/

相关文章:

html - 使用 CSS 设置箭头的永久位置,而不影响表格单元格中的文本对齐

javascript - 如何在 HTML Canvas 中使用不同颜色的文本

javascript - jQuery 中的直接子选择器

html - iframe 不适用于页脚

php - 添加自定义属性 Wordpress 导航项

javascript - 绘制形状(N 边形)

html - 如何在 Rmarkdown html 输出中有一个 float 图像?

javascript - CSS 高度在 Firefox 中不起作用

javascript - 原型(prototype)和 jQuery 连接失败

firefox - 从 Firefox 粘贴到 PHPStorm IDE 不起作用