Вариант 1:
Пример сделан на базе списка ul li
, в котором первая ссылка заменяется на изображение домика. Если последний элемент списка не имеет ссылку, то он должен быть обрамлен тегом span
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<ul class="breadcrumb-1"> <li> <a href="#link">Главная</a> </li> <li> <a href="#link">Каталог</a> </li> <li> <a href="#link">Хлебные крошки</a> </li> <li> <span>Последний элемент</span> </li> </ul> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
ul.breadcrumb-1 * { box-sizing: border-box; } ul.breadcrumb-1 { margin: 20px; padding: 0; display: flex; flex-wrap: wrap; list-style: none; } ul.breadcrumb-1 li { position: relative; border: 2px solid #337AB7; border-right: 0; margin: 2px 0; } ul.breadcrumb-1 li:last-child { border: 2px solid #BFE2FF; border-right: 0; } ul.breadcrumb-1 li:first-child a { font-size: 0; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23337AB7' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' class='feather feather-home'%3E%3Cpath d='M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'%3E%3C/path%3E%3Cpolyline points='9 22 9 12 15 12 15 22'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 50% 50%; } ul.breadcrumb-1 li:first-child:after, ul.breadcrumb-1 li:first-child a:after { display: none; } ul.breadcrumb-1 li:after, ul.breadcrumb-1 li a:after, ul.breadcrumb-1 li span:after { content: ''; position: absolute; border: 0; top: 50%; } ul.breadcrumb-1 li:after { z-index: 1; border-top: 17px solid transparent; border-bottom: 17px solid transparent; border-left: 17px solid #337AB7; margin-top: -17px; right: -17px; } ul.breadcrumb-1 li:last-child:after { border-left: 17px solid #BFE2FF; } ul.breadcrumb-1 li a, ul.breadcrumb-1 li span { position: relative; transition: all 0.3s ease-in; text-decoration: none; height: 30px; color: #000; background-color: #BFE2FF; text-align: center; display: block; line-height: 30px; padding: 0 20px 0 30px; font-size: 13px; font-family: Verdana, sans-serif; } ul.breadcrumb-1 li span { color: #000; background-color: #FFF; } ul.breadcrumb-1 li a:after, ul.breadcrumb-1 li span:after { transition: all 0.3s ease-in; z-index: 2; border-top: 15px solid transparent; border-bottom: 15px solid transparent; border-left: 15px solid #BFE2FF; margin-top: -15px; right: -14px; } ul.breadcrumb-1 li a:hover { background-color: #FFF; } ul.breadcrumb-1 li a:hover:after, ul.breadcrumb-1 li span:after { border-left: 15px solid #FFF; } |
Вариант 2:
В этом примере ссылки следуют одна за другой, а последний элемент цепочки, как и в предыдущем примере, обрамлен тегом span
.
1 2 3 4 5 6 |
<div class="breadcrumb-2"> <a href="#link">Главная</a> <a href="#link">Каталог</a> <a href="#link">Хлебные крошки</a> <span>Последний элемент</span> </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
.breadcrumb-2 * { box-sizing: border-box; margin: 0; padding: 0 } .breadcrumb-2 { display: flex; flex-wrap: wrap; counter-reset: flag; margin: 20px; } .breadcrumb-2 a, .breadcrumb-2 span { background: white; color: black; transition: all 0.5s; text-decoration: none; outline: none; font-size: 12px; line-height: 36px; padding: 0 10px 0 60px; position: relative; font-size: 13px; font-family: Verdana, sans-serif; border: 2px solid #BFE2FF; border-right: 0; margin: 2px 0; border-radius: 8px 0 0 8px; } .breadcrumb-2 a:first-child { padding-left: 46px; } .breadcrumb-2 a:first-child:before { left: 14px; } .breadcrumb-2 a:hover{ background: #BFE2FF; } .breadcrumb-2 a:hover:after { background: #BFE2FF; } .breadcrumb-2 a:after, .breadcrumb-2 span:after { content: ''; position: absolute; top: 0; right: -18px; width: 36px; height: 36px; transform: scale(0.7) rotate(45deg); z-index: 1; box-shadow: 2px -2px 0 2px #BFE2FF; border-radius: 0 5px 0 50px; background: white; transition: all 0.5s; } .breadcrumb-2 a:before, .breadcrumb-2 span:before { content: counter(flag); counter-increment: flag; border-radius: 50%; width: 20px; height: 20px; text-align: center; font-size: 11px; line-height: 20px; margin: 8px 0; position: absolute; top: 0; left: 30px; font-weight: bold; background: white; box-shadow: 0 0 0 1px #ccc; } |
Вариант 3:
Вариант сделан на базе списка ul li
, в котором вся цепочка состоит из ссылок. Четные и нечетные имеют разный фон.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<ul class="breadcrumb-3"> <li> <a href="#link">Главная</a> </li> <li> <a href="#link">Каталог</a> </li> <li> <a href="#link">Хлебные крошки</a> </li> <li> <a href="#link">Последний элемент</a> </li> </ul> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
ul.breadcrumb-3 { list-style: none; display: flex; flex-wrap: wrap; margin: 20px; padding: 0; } ul.breadcrumb-3 li { margin: 2px 0; } ul.breadcrumb-3 li a { color: #FFF; display: block; background: #337AB7; text-decoration: none; position: relative; height: 30px; line-height: 30px; padding: 0 10px 0 5px; text-align: center; margin-right: 23px; font-size: 13px; font-family: Verdana, sans-serif; transition: all 0.3s; } ul.breadcrumb-3 li:nth-child(even) a { background-color: #2d6b9f; } ul.breadcrumb-3 li:nth-child(even) a:before { border-color: #2d6b9f; border-left-color: transparent; } ul.breadcrumb-3 li:nth-child(even) a:after { border-left-color: #2d6b9f; } ul.breadcrumb-3 li:first-child a { padding-left: 15px; border-radius: 4px 0 0 4px; } ul.breadcrumb-3 li:first-child a:before { border: none; } ul.breadcrumb-3 li:last-child a { padding-right: 15px; border-radius: 0 4px 4px 0; } ul.breadcrumb-3 li:last-child a:after { border: none; } ul.breadcrumb-3 li a:before, ul.breadcrumb-3 li a:after { content: ""; position: absolute; top: 0; border: 0 solid #337AB7; border-width: 15px 10px; width: 0; height: 0; transition: all 0.3s; } ul.breadcrumb-3 li a:before { left: -20px; border-left-color: transparent; } ul.breadcrumb-3 li a:after { left: 100%; border-color: transparent; border-left-color: #337AB7; } ul.breadcrumb-3 li a:hover { background-color: #BFE2FF; color: #000; } ul.breadcrumb-3 li a:hover:before { border-color: #BFE2FF; border-left-color: transparent; } ul.breadcrumb-3 li a:hover:after { border-left-color: #BFE2FF; } |
Вариант 4:
Похожий на предыдущий пример, только без использования списков.
1 2 3 4 5 6 |
<div class="breadcrumb-4"> <a href="#link">Главная</a> <a href="#link">Каталог</a> <a href="#link">Хлебные крошки</a> <a href="#link">Последний элемент</a> </div> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
.breadcrumb-4 { line-height: 30px; font-size: 13px; height: 30px; margin: 20px; display: flex; flex-wrap: wrap; font-family: Verdana, sans-serif; } .breadcrumb-4 a { position: relative; background: #337AB7; color: #fff; text-decoration: none; padding: 0 10px 0 20px; transition: all 0.3s; } .breadcrumb-4 a:before { content: ""; left: 0; top: 0; display: block; position: absolute; border-width: 15px 0 15px 10px; border-style: solid; border-color: transparent transparent transparent #337AB7; transition: all 0.3s; } .breadcrumb-4 a:hover { background: #BFE2FF; color: #000; } .breadcrumb-4 a:hover + a:before { border-color: transparent transparent transparent #BFE2FF; } .breadcrumb-4 a:first-child { border-radius: 6px 0 0 6px; } .breadcrumb-4 a:first-child:before { display: none; } .breadcrumb-4 a:last-child { padding-right: 20px; border-radius: 0 6px 6px 0; } |
Вариант 5:
Самый простой вариант списком ul li
и наиболее используемый. Последний элемент может быть, как ссылкой, так и вовсе не иметь тега. Размер стрелочки задается высотой строки line-height
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<ul class="breadcrumb-5"> <li> <a href="#link">Главная</a> </li> <li> <a href="#link">Каталог</a> </li> <li> <a href="#link">Хлебные крошки</a> </li> <li> Последний элемент </li> </ul> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
ul.breadcrumb-5 { margin: 20px; padding: 0; } ul.breadcrumb-5 li { display: inline-block; line-height: 20px; margin: 0 5px 0 -10px; padding: 0 20px; position: relative; font-size: 13px; font-family: Verdana, sans-serif; } ul.breadcrumb-5 li:before, ul.breadcrumb-5 li:after { border-right: 3px solid #BFE2FF; content: ''; display: block; height: 50%; position: absolute; left: 0; right: 0; top: 0; z-index: -1; transform: skewX(45deg); } ul.breadcrumb-5 li:after { bottom: 0; top: auto; transform: skewX(-45deg); } ul.breadcrumb-5 li:last-of-type:before, ul.breadcrumb-5 li:last-of-type:after { display: none; } ul.breadcrumb-5 li a { color: #000; text-decoration: none; transition: all 0.3s; } ul.breadcrumb-5 li a:hover { color: #337AB7; } |
Здравствуйте
А как сделать так, чтобы left -20 был вровень с первым уровнем при переносе (так выглядит у меня в мобильной версии). Подскажите, что поправить?
Скрин:
фото на фотогостинге radikal
Спасибо!