小编Kar*_*ger的帖子

使用CSS:after伪选择器在Bootstrap 3输入组中显示定向插入符

我一直在尝试将Bootstrap 3中的插入符号应用于输入组元素。尝试对插入的伪元素使用表单元格显示,尝试绝对定位,尝试使用content属性显示Web字体插入符号,而不是我喜欢的CSS三角形插入符号。只是不能把我的头缠在这一个。

这是一个JSFiddle(红色边框是我希望插入符号显示的位置)。

.input-group .input-group-addon:last-child:before,
.input-group .input-group-btn:last-child:before,
.input-group .input-group-addon:not(:last-child):before,
.input-group .input-group-btn:not(:last-child):before {
  position: absolute;
  content: '';
  width: 0;
  height: 0;
  border: 10px solid transparent;
  margin: auto;
  top: 0;
  bottom: 0;
  z-index: 1000;
}

.input-group .input-group-addon:last-child:before,
.input-group .input-group-btn:last-child:before {
  border-right-color: red;
  right: 0;
}

.input-group .input-group-addon:not(:last-child):before,
.input-group .input-group-btn:not(:last-child):before {
  border-left-color: red;
  left: 0;
}
Run Code Online (Sandbox Code Playgroud)

编辑:根据一个答案,我修改了样式,该样式现在可以在IE10及以下版本中正常使用。IE偏移了左对齐的input-group插入符号,4px如http://jsfiddle.net/W8mFS/3/所示。任何想法如何解决这个问题?

更新的CSS:

.input-group.input-group-caret span:after,
.input-group.input-group-caret > input + span:before {
  position: absolute;
  content: '';
  width: 0;
  height: 0;
  top: …
Run Code Online (Sandbox Code Playgroud)

css pseudo-element twitter-bootstrap twitter-bootstrap-3

3
推荐指数
1
解决办法
7845
查看次数