Bootstrap如何在面包屑组件中添加“ /”?

迦勒·杰(Caleb Jay)

v3和v4中的Bootstrap面包屑组件在列表项中添加了一个“ /”:

http://getbootstrap.com/components/#breadcrumbs

https://v4-alpha.getbootstrap.com/components/breadcrumb/

文档说:

分隔符通过:: before和content自动添加到CSS中。

因此,我查看了源代码,相关部分显示了:

.breadcrumb-item + .breadcrumb-item::before {
  display: inline-block;
  padding-right: 0.5rem;
  padding-left: 0.5rem;
  color: #636c72;
  content: "/";
}

但是,规则content: "/";上唯一存在breadcrumb-item但是,当我遵循v3文档时,它似乎可以工作,该文档不需要一个breadcrumb-item用于列表内项目类:

<ol class="breadcrumb">
  <li class=''><a href="#">Home</a></li>
  <li class=''><a href="#">Library</a></li>
  <li class="active">Data</li>
</ol>

JSFiddle

为什么上面的HTML和上面的CSS会导致将/分隔符添加到.breadcrumb列表中的项目,即使它们没有.breadcrumb-item类,因此也无法从content: "/"规则中受益呢?在JSFiddle中检查输出HTML,表明没有引导Javascript魔术将.breadcrumb-item添加到我的html列表项中。

Dalin Huang

链接到github(bootstrap v3.3.7)上的这种样式:

https://github.com/twbs/bootstrap/blob/v3.3.7/less/breadcrumbs.less

对于(bootstrap v4.0.0):

https://github.com/twbs/bootstrap/blob/v4.0.0-alpha.6/scss/_breadcrumb.scss

(bootstrap v3.3.7->面包屑.less)

//
// Breadcrumbs
// --------------------------------------------------


.breadcrumb {
  padding: @breadcrumb-padding-vertical @breadcrumb-padding-horizontal;
  margin-bottom: @line-height-computed;
  list-style: none;
  background-color: @breadcrumb-bg;
  border-radius: @border-radius-base;

  > li {
    display: inline-block;

    + li:before {
      content: "@{breadcrumb-separator}\00a0"; // Unicode space added since inline-block means non-collapsing white-space
      padding: 0 5px;
      color: @breadcrumb-color;
    }
  }

  > .active {
    color: @breadcrumb-active-color;
  }
}

(bootstrap v4.0.0-> _breadcrumb.scss)

.breadcrumb {
  padding: $breadcrumb-padding-y $breadcrumb-padding-x;
  margin-bottom: $spacer-y;
  list-style: none;
  background-color: $breadcrumb-bg;
  @include border-radius($border-radius);
  @include clearfix;
}

.breadcrumb-item {
  float: left;

  // The separator between breadcrumbs (by default, a forward-slash: "/")
  + .breadcrumb-item::before {
    display: inline-block; // Suppress underlining of the separator in modern browsers
    padding-right: $breadcrumb-item-padding;
    padding-left: $breadcrumb-item-padding;
    color: $breadcrumb-divider-color;
    content: "#{$breadcrumb-divider}";
  }

  // IE9-11 hack to properly handle hyperlink underlines for breadcrumbs built
  // without `<ul>`s. The `::before` pseudo-element generates an element
  // *within* the .breadcrumb-item and thereby inherits the `text-decoration`.
  //
  // To trick IE into suppressing the underline, we give the pseudo-element an
  // underline and then immediately remove it.
  + .breadcrumb-item:hover::before {
    text-decoration: underline;
  }
  + .breadcrumb-item:hover::before {
    text-decoration: none;
  }

  &.active {
    color: $breadcrumb-active-color;
  }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在Wordpress中从面包屑中删除“主页”

如何在Bootstrap 4中的面包屑元素右边插入按钮?

如何在Schema.org中向产品添加面包屑?

如何在Magento 2中为子主题添加和应用面包屑.phtml?

如何在 opencart 中创建面包屑

如何在Eclipse中禁用面包屑

如何在可视代码中复制HTML面包屑?

在Flutter中添加Sentry面包屑

面包屑在angularjs中如何使用?

角度5在某些组件中具有面包屑

如何在两个面包屑之间添加gt符号?

如何删除bootstrap面包屑轮廓边框颜色?

从 Bootstrap 4 面包屑中删除边界半径 - Sass

Bootstrap 3中的面包屑的下拉菜单

在Bootstrap 4面包屑中右对齐文本

如何更改Bootstrap 3面包屑中的默认分隔符图标?

如何通过JSON / JS在Jenkins中为CSRF添加面包屑

如何在Vue.js中的URL面包屑中获取路径的参数

如何在wordpress中的一行中显示面包屑?

如何在Visual Studio Code上显示面包屑?

如何在ng-click上使用面包屑?

如何在纯 MySQL 中生成类别面包屑?

如何在Nuxt.js中创建动态的“面包屑”

如何在magento的面包屑页面中显示类别描述?

使用MVC站点地图时,如何在面包屑中更改父级父级?

如何在Visual Studio Code中删除代码结构视图或“面包屑”?

我如何在TYPO3的Extbase Frontent插件中获得根线/面包屑

如果点数太多,如何在分页或面包屑中创建点

如何在此面包屑模式 JSON 生成器中显示位置编号