制作面包屑...不像实际制作面包屑那么容易,我该如何将文字放在里面?

StackOverflow https://stackoverflow.com/questions/19846836

  •  29-07-2022
  •  | 
  •  

所以我通过代码制作了一些面包屑

http://line25.com/tutorials/how-to-to-create-flat-style-breadcrumb-ninks-with-css

...而且我只能按照自己的喜好,只为我的生活,我不知道如何将文字放入框中...问题是它们是单独存在的,我可以使用行 - 高度将文本进一步推向页面,但是我不能使用负面数字来推开文本。

编辑:我知道link25的代码在内部文本中正常工作,这是因为我缩小了容器,所以我有这个问题...

有任何想法吗?

这是HTML(StackOverFlow一直在翻译它):HTML

和CSS:

body {
margin: 0px;
font-family: 'Roboto';
background: #eeeeee; }

crumbs {text-align:中心; }

#crumbs ul {
    list-style:none;
    display: inline-table;

}

    #crumbs ul li { display: inline-block; }

        #crumbs ul li a {    /* The block part of each breadcrumb; the text in each breadcrumb */
            display: block;
            float: left;
            height: 0px;
            background: #327098;
            /*text-align: center; */
            padding: 30px 10px 0 80px;  /* size of each breadcrumb  */
            position: relative;
            margin: 0 5px 0 0;
            font-size: 16px;
            text-decoration: none;
            color: #000000; }

            #crumbs ul li a:after { /* The triangle to the right of each breadcrumb */
                content: "";
                border-top: 15px solid transparent;
                border-bottom: 15px solid transparent;
                border-left: 15px solid #327098;
                position: absolute;
                right: -15px;
                top: 0;
                z-index: 1; }

            #crumbs ul li a:before {    /* the triangle to the left of each breadcrumb  */
                content: "";
                border-top: 15px solid transparent;
                border-bottom: 15px solid transparent;
                border-left: 15px solid #eeeeee;
                position: absolute;
                left: 0;
                top: 0; }

        #crumbs ul li:first-child a {    /* what makes the first breadcrumb have a rounded left side */
            border-top-left-radius: 10px;
            border-bottom-left-radius: 10px; }

            #crumbs ul li:first-child a:before { display: none; }

        #crumbs ul li:last-child a {
            padding-right: 80px;    /* the width of the last breadcrumb */
            border-top-right-radius: 10px;  /* Makes the right side of the last breadcrumb rounded */
            border-bottom-right-radius: 10px; } /* rounded */

            #crumbs ul li:last-child a:after { display: none; }

        #crumbs ul li a:hover { background: #c9c9c9; }   /* a hover color for breadcrumbs, exclu. triangle-right    */

            #crumbs ul li a:hover:after { border-left-color: #c9c9c9; } /* a hover color for triangle-right */
有帮助吗?

解决方案

http://jsfiddle.net/zh6bw/1/

这是由于锚的顶部填充物等于您想要的碎屑的高度。我卸下了填充物,给了包含的列表元素 height:30px;, ,给锚 line-height:30px; 因此它们保持垂直为中心。

#crumbs ul li { 
    display: inline-block; 
    height:30px;
}

#crumbs ul li a {    /* The block part of each breadcrumb; the text in each breadcrumb */
    display: block;
    line-height:30px;
    background: #327098;
    /*text-align: center; */
    padding: 0 10px 0 80px;  /* size of each breadcrumb  */
    position: relative;
    margin: 0 5px 0 0;
    font-size: 16px;
    text-decoration: none;
    color: #000000;
}

编辑

我不确定他们分别存在的意思。我只是将您提供的代码复制到小提琴中并运行了。我看到了明显的问题,我竭尽所能。这是我看到的问题。 http://jsfiddle.net/zh6bw/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top