【问题标题】:css breadcrumbs breaks into 2 lines, how to controll it in responsive?CSS面包屑分为两行,如何控制它的响应?
【发布时间】:2016-07-07 12:07:28
【问题描述】:

我有一个面包屑列表,它看起来像这样:

但是如果步骤太多或者在分辨率较低的设备上查看它就会崩溃并且变得丑陋,如下所示:

我的代码是这样的:

ul.breadcrumb li { 
padding-left: 5px;
}
ul.breadcrumb li::after {
  display: inline-block;
  color: #959fa5;
}
ul.breadcrumb li::after {
  content: '';
  height: 25px;
  width: 12px;
  background: url(/theme/base/pix/grey-white-grey2.png) no-repeat center center;
  vertical-align: middle;
}
ul.breadcrumb li {
  background-color:@color-gery-background;
}
ul.breadcrumb li:nth-last-child(2):after {
  content: '';
  height: 25px;
  width: 12px;
  margin-right: 0px;
  background: url(/theme/base/pix/grey-white-blue.png) no-repeat center center;
  vertical-align: middle;
}
ul.breadcrumb li:last-child{
  background-color: @color-blue;
  text-shadow: none;
  color: white!important;
}
ul.breadcrumb li:last-child a,
ul.breadcrumb li:last-child span
{
  text-shadow: none;
  color: white!important;
}
ul.breadcrumb li:last-child:after
 {
  content: ' ';
  height: 25px;
  width: 12px;
  vertical-align: middle;
  background: url(/theme/base/pix/blue-whitey.png) no-repeat center center;
}
ul.breadcrumb li > *:last-child::before,
.cd-multi-steps.custom-icons li > *::before {
  content: ' ';
  height: 25px;
  width: 12px;
  vertical-align: middle;
  background: url(/theme/base/pix/blue-whitey.png) no-repeat center center;
}

和 HTML

<ul class="breadcrumb">
  <li><a href="#">My home</a></li>
  <li><span>some text</span></li>
  <li><a href="#">Some link</a></li>
</ul>

而且由于我正在使用moodle,因此我无法在li 上设置更多类,而li 的内容要么是链接,要么只是带有文本的跨度。 (并且没有任何特定的顺序) 我可以以某种方式使它成为最后一个选项,而不是像现在这样的图像 - 我尝试了一些其他带有边界三角形的示例,但它们也没有响应:-/

【问题讨论】:

  • 所以..你想做什么?让所有面包屑保持在 1 行?不改变他们的风格(字体大小 .width 等)
  • 解决方法可能是,当屏幕较小时,第二个最后一个孩子与最后一个孩子在下一行,因此它不会在蓝色中中断

标签: jquery css moodle breadcrumbs


【解决方案1】:

你能做什么?

  1. 不要使用图像作为面包屑,而是使用 CSS
  2. 更改小屏幕上的 CSS,使其不难看。

喜欢,

/* some breadcrumb basic code */

@media only screen and (max-width : 766px) {
    ... code for small devices ...
}

@media only screen and (min-width : 767px) {
    ... code for large devices ...
}

Check this fiddle 并尝试调整结果窗口的大小

This is updated fiddle

【讨论】:

  • 我已经尝试过使用谷歌的 CSS 三角形,但我没有按预期工作。我在清理 lis 的第一个孩子变坏时遇到了一些严重的麻烦。另一个问题是,每个面包屑中的文本可能很长,所以如果我可以控制面包屑的破坏
  • @HenrikSunePedersen 你检查过小提琴吗?如果没有,请通过它。并尝试调整结果窗口的大小
  • _是的,我看到了小提琴,并试图重新调整。问题是一样的,“蓝色”可以分成两行。 screencast.com/t/5HFtaOMmlEfW
  • @HenrikSunePedersen 检查上面更新的小提琴。我认为它可以按您的意愿工作。 :-)(并尝试调整结果窗口的大小)
  • 稍微修改了脚本并使其正常工作 - 非常感谢您的帮助:-)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-15
  • 1970-01-01
相关资源
最近更新 更多