jquery - 当视口(viewport)很窄时,强制面包屑元素不会中断到另一行

标签 jquery html css responsive-design breadcrumbs

我正在尝试创建具有箭头外观的面包屑。这就是设计。

请注意,当文本太长时,每个面包屑项中的文本会多行。

enter image description here

我们可以假设始终最多有 4 个面包屑:

  • 首页
  • 第一类
  • 点(针对类别较多的情况)
  • 最后一类

我有一个解决方案,但由于设计是响应式的,该解决方案根本不适用于窄视口(viewport)。当面包屑项中的文本太长时,它会一直排成一行,从而使面包屑项变长。然后,当视口(viewport)变窄时,整个面包屑项就会换行。错了!

我使用 Bootstrap。

知道如何解决这个问题吗?

这是 fiddle :http://jsfiddle.net/aeoLcm1m/

HTML:

<ul class="breadcrumb noppadinglr">
  <li><a href="#" class="home"></a></li>
  <li><a href="#">Vehicles</a></li>
  <li><a href="#" class="dots">...</a></li>
  <li><a href="#">1989 VW Westfalia Vanagon</a></li>
</ul> 

CSS:

.breadcrumb {
  list-style: none;
  overflow: hidden;
  margin-bottom: 0px;
  border: 0px transparent;
  border-bottom: 2px solid #fff;
  padding: 0px;
  background: white;
  white-space: nowrap;
}
.breadcrumb .home {
  background: #d3d3d3 url(img/ico/ico-house.png) right center no-repeat;
  width: 40px;
  height: 48px;
  display: block;
}
.breadcrumb img {
  width: 75%;
  max-height: 18px;
}
.breadcrumb .dots {
  padding: 18px 0 10px 20px;
}
.breadcrumb li {
  float: left;
  display: inline-block;
  list-style: none;
}
.breadcrumb li a {
  color: black;
  text-decoration: none;
  padding: 18px 0 10px 40px;
  background: lightgrey;
  position: relative;
  display: inline-block;
  float: left;
}
.breadcrumb li a::after {
  content: " ";
  display: block;
  width: 0;
  height: 0;
  border-color: transparent transparent transparent lightgrey;
  border-width: 50px 0px 50px 30px;
  border-style: solid;
  position: absolute;
  top: 50%;
  margin-top: -50px;
  left: 100%;
  z-index: 2;
}
.breadcrumb li a::before {
  content: " ";
  display: block;
  width: 0;
  height: 0;
  border-color: transparent transparent transparent blue;
  border-width: 50px 0px 50px 30px;
  border-style: solid;
  position: absolute;
  top: 50%;
  margin-top: -50px;
  margin-left: 1px;
  left: 100%;
  z-index: 1;
}
.breadcrumb li:first-child a {
  padding-left: 10px;
}
.breadcrumb li:last-child a {
  background: lightblue !important;
  pointer-events: none;
  cursor: default;
}
.breadcrumb li:last-child a:after {
  border-left-color: lightblue;
}

最佳答案

您必须直接为链接定义空白属性

.breadcrumbs li a {
    white-space: nowrap;
}

关于jquery - 当视口(viewport)很窄时,强制面包屑元素不会中断到另一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25323383/

相关文章:

javascript - 如何根据查询字符串参数将元素标记为选中

html - 垂直对齐导航链接文本

javascript - 使用日期选择器关注下一个表单元素

css - 如何在 VS Code 中为 css 添加自动完成

javascript - 多行轮播居中

html - App Discovery 小部件强制隐藏

javascript - JQuery 在使用 PHP 的 json_encode 时给出 JSON 语法错误

jquery - 使用 jQuery 更改 href 文件但不更改查询字符串

javascript - jquery在appendTo之后无法聚焦于输入框

jquery - 从多选下拉列表中的 optgroup 选项中仅选择一个