Making breadcrumbs... not as easy as literally making breadcrumbs, how can I get text to be inside?

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

  •  29-07-2022
  •  | 
  •  

Question

So I made some breadcrumbs via the code from

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

... And I got everything to just the way I like it, only for the life of me, I can't figure out how to get the text inside the boxes... The issue is they exist separately, I can use line-height to push the text down the page even further, however I can not use a negative number to push the text up.... same goes for margin-top...

EDIT: I know the code from link25 works fine for the text being inside, it's because I shrunk the containers that I have this problem...

Any ideas?

Here's the HTML (StackOverflow keeps translating it):HTML

And the CSS:

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

crumbs { text-align: center; }

#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 */
Was it helpful?

Solution

http://jsfiddle.net/ZH6BW/1/

It's caused by your anchors having a top padding equal to the height you want the crumbs to have. I removed that padding, gave the containing list element height:30px;, gave the anchors line-height:30px; so they remain vertically centered.

#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;
}

Edit

I'm not sure what you mean by them existing separately. I just copied the code you provided into a fiddle and ran it. And I saw the apparent issue and I did what I could. Here's the issue that I saw. http://jsfiddle.net/ZH6BW/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top