javascript - 如何更改 Bootstrap 标签输入的样式

标签 javascript css bootstrap-4 bootstrap-tags-input

我有一个带有 bootstrap tagsinput 的输入字段,问题是当标签被激活时我没有标签框。

例如我有这个: enter image description here

我想要这样的东西:

enter image description here

通过创建一个小盒子显示标签 python 和 java 被激活。

我在示例中使用这种样式:

 <style>



.bootstrap-tagsinput {
  background-color: #fff;
  border: 1px solid #ccc;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
  display: inline-block;
  padding: 4px 6px;
  color: #555;
  vertical-align: middle;
  border-radius: 4px;
  max-width: 100%;
  line-height: 22px;
  cursor: text;
}
.bootstrap-tagsinput input {
  border: none;
  box-shadow: none;
  outline: none;
  background-color: transparent;
  padding: 0 6px;
  margin: 0;
  width: auto;
  max-width: inherit;
}
.bootstrap-tagsinput.form-control input::-moz-placeholder {
  color: rgb(170, 36, 36);
  opacity: 1;
}
.bootstrap-tagsinput.form-control input:-ms-input-placeholder {
  color: #777;
}
.bootstrap-tagsinput.form-control input::-webkit-input-placeholder {
  color: #777;
}
.bootstrap-tagsinput input:focus {
  border: none;
  box-shadow: none;
}
.bootstrap-tagsinput .tag {
  margin-right: 2px;
  color: black;
}
.bootstrap-tagsinput .tag [data-role="remove"] {
  margin-left: 8px;
  cursor: pointer;
}
.bootstrap-tagsinput .tag [data-role="remove"]:after {
  content: "x";
  padding: 0px 2px;
}
.bootstrap-tagsinput .tag [data-role="remove"]:hover {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
.bootstrap-tagsinput .tag [data-role="remove"]:hover:active {
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
}

</style>

最佳答案

我通过添加这个解决了我的问题:

.bootstrap-tagsinput .tag {
  background: gray;
  border: 1px solid black;
  padding: 0 6px;
  margin-right: 2px;
  color: white;
  border-radius: 4px;
}

关于javascript - 如何更改 Bootstrap 标签输入的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57693586/

相关文章:

javascript - d3js 箭头不显示

javascript - 如何使用 Javascript 和 Ajax 将 HTML 单选按钮值传递给 PHP 变量?

javascript - 完全可定制的布局?

html - 不去 AngularJs 中的特定 URL this.router.navigate()

javascript - Bootstrap 4轮播循环方法

javascript - Bootstrap4 对齐 self 基线不起作用

php - 如何使用jquery从iframe包含的html页面中删除第一个div

javascript - ng-style 未应用在 Angular ng-repeat

javascript - 将 css 类应用于传单层

html - 包含多个重叠 div 的匹配容器