2016-03-08 149 views
1

所以我有一个面包屑导航箭头间隔。棘手的是我需要它做出反应。我想我正在使用vh和vw,但是我遇到的问题是白色隔离层没有像之前的箭头那样响应。有什么建议么?还是有更好的方法来处理它?我尝试了一堆东西,但似乎没有工作。任何帮助是极大的赞赏。小提琴包括响应箭头Breadcrumb导航

https://jsfiddle.net/8v9ctam0/

/* ---------------------- 
 
    
 
General Styling 
 
    
 
------------------------*/ 
 
    
 
* { 
 
    margin: 0; 
 
    padding: 0; 
 
    -moz-box-sizing: border-box; 
 
    -webkit-box-sizing: border-box; 
 
    box-sizing: border-box; 
 
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 
 
} 
 
    
 
.cd-breadcrumb, .cd-multi-steps { 
 
    padding: 0.5em 1em; 
 
    margin: 1em auto; 
 
    background-color: #edeff0; 
 
    border-radius: .25em; 
 
} 
 
.cd-breadcrumb:after, .cd-multi-steps:after { 
 
    content: ""; 
 
    display: table; 
 
    clear: both; 
 
} 
 
.cd-breadcrumb li, .cd-multi-steps li { 
 
    display: inline-block; 
 
    float: left; 
 
    margin: 0.5em 0; 
 
} 
 
.cd-breadcrumb li::after, .cd-multi-steps li::after { 
 
    /* this is the separator between items */ 
 
    display: inline-block; 
 
    content: '\00bb'; 
 
    margin: 0 .6em; 
 
    color: #959fa5; 
 
} 
 
.cd-breadcrumb li:last-of-type::after, .cd-multi-steps li:last-of-type::after { 
 
    /* hide separator after the last item */ 
 
    display: none; 
 
} 
 
.cd-breadcrumb li > *, .cd-multi-steps li > * { 
 
    /* single step */ 
 
    display: inline-block; 
 
    font-size: 1.0vw; 
 
    color: #2c3f4c; 
 
} 
 
.cd-breadcrumb li.current > *, .cd-multi-steps li.current > * { 
 
    /* selected step */ 
 
    color: #96c03d; 
 
} 
 
.no-touch .cd-breadcrumb a:hover, .no-touch .cd-multi-steps a:hover { 
 
    /* steps already visited */ 
 
    color: #96c03d; 
 
} 
 
.cd-breadcrumb.custom-separator li::after, .cd-multi-steps.custom-separator li::after { 
 
    /* replace the default arrow separator with a custom icon */ 
 
    content: ''; 
 
    height: 16px; 
 
    width: 16px; 
 
    background: url(../img/cd-custom-separator.svg) no-repeat center center; 
 
    vertical-align: middle; 
 
} 
 
.cd-breadcrumb.custom-icons li > *::before, .cd-multi-steps.custom-icons li > *::before { 
 
    /* add a custom icon before each item */ 
 
    content: ''; 
 
    display: inline-block; 
 
    height: 20px; 
 
    width: 20px; 
 
    margin-right: .4em; 
 
    margin-top: -2px; 
 
    background: url(../img/cd-custom-icons-01.svg) no-repeat 0 0; 
 
    vertical-align: middle; 
 
} 
 
.cd-breadcrumb.custom-icons li:not(.current):nth-of-type(2) > *::before, .cd-multi-steps.custom-icons li:not(.current):nth-of-type(2) > *::before { 
 
    /* change custom icon using image sprites */ 
 
    background-position: -20px 0; 
 
} 
 
.cd-breadcrumb.custom-icons li:not(.current):nth-of-type(3) > *::before, .cd-multi-steps.custom-icons li:not(.current):nth-of-type(3) > *::before { 
 
    background-position: -40px 0; 
 
} 
 
.cd-breadcrumb.custom-icons li:not(.current):nth-of-type(4) > *::before, .cd-multi-steps.custom-icons li:not(.current):nth-of-type(4) > *::before { 
 
    background-position: -60px 0; 
 
} 
 
.cd-breadcrumb.custom-icons li.current:first-of-type > *::before, .cd-multi-steps.custom-icons li.current:first-of-type > *::before { 
 
    /* change custom icon for the current item */ 
 
    background-position: 0 -20px; 
 
} 
 
.cd-breadcrumb.custom-icons li.current:nth-of-type(2) > *::before, .cd-multi-steps.custom-icons li.current:nth-of-type(2) > *::before { 
 
    background-position: -20px -20px; 
 
} 
 
.cd-breadcrumb.custom-icons li.current:nth-of-type(3) > *::before, .cd-multi-steps.custom-icons li.current:nth-of-type(3) > *::before { 
 
    background-position: -40px -20px; 
 
} 
 
.cd-breadcrumb.custom-icons li.current:nth-of-type(4) > *::before, .cd-multi-steps.custom-icons li.current:nth-of-type(4) > *::before { 
 
    background-position: -60px -20px; 
 
} 
 
@media only screen and (min-width: 768px) { 
 
    .cd-breadcrumb, .cd-multi-steps { 
 
    padding: 0 1.2em; 
 
    } 
 
    .cd-breadcrumb li, .cd-multi-steps li { 
 
    margin: 1.2em 0; 
 
    } 
 
    .cd-breadcrumb li::after, .cd-multi-steps li::after { 
 
    margin: 0 1em; 
 
    } 
 
} 
 

 

 
/* -------------------------------- 
 

 
Triangle breadcrumb 
 

 
-------------------------------- */ 
 

 
    .cd-breadcrumb.triangle { 
 
    /* reset basic style */ 
 
    background-color: transparent; 
 
    padding: 0; 
 
    } 
 
    
 
    .cd-breadcrumb.triangle li { 
 
    position: relative; 
 
    padding: 0; 
 
    margin: 4px 4px 4px 4px; 
 
    } 
 
    
 
    .checkout { 
 
    max-height: 5.0vh; 
 
    line-height: 2.5vh; 
 
    } 
 
     
 
    .cd-breadcrumb.triangle li strong { 
 
    display: block; 
 
    } 
 
    
 
    .cd-breadcrumb.triangle li:last-of-type { 
 
    margin-right: 0; 
 
    } 
 
    .cd-breadcrumb.triangle li > * { 
 
    position: relative; 
 
    padding: 1em .8em 1em 2.5em; 
 
    color: #2c3f4c; 
 
    background-color: #edeff0; 
 
    /* the border color is used to style its ::after pseudo-element */ 
 
    border-color: #edeff0; 
 
    } 
 
    .cd-breadcrumb.triangle li.current > * { 
 
    /* selected step */ 
 
    color: #ffffff; 
 
    background-color: #F00; 
 
    border-color: #F00; 
 
    } 
 
    .cd-breadcrumb.triangle li:first-of-type > * { 
 
    padding-left: 1.6em; 
 
    } 
 
    .cd-breadcrumb.triangle li:last-of-type > * { 
 
    padding-right: 1.6em; 
 
    } 
 
    .no-touch .cd-breadcrumb.triangle a:hover { 
 
    /* steps already visited */ 
 
    color: #ffffff; 
 
    background-color: #2c3f4c; 
 
    border-color: #2c3f4c; 
 
    } 
 
    .cd-breadcrumb.triangle li::after, .cd-breadcrumb.triangle li > *::after { 
 
    /* 
 
    \t li > *::after is the colored triangle after each item 
 
    \t li::after is the white separator between two items 
 
    */ 
 
    content: ''; 
 
    position: absolute; 
 
    top: 0; 
 
    left: 100%; 
 
    content: ''; 
 
    height: 0; 
 
    width: 0; 
 
    /* 48px is the height of the <a> element */ 
 
    border: 2.1em solid transparent; 
 
    border-right-width: 0; 
 
    border-left-width: 0.8em; 
 
    } 
 
    .cd-breadcrumb.triangle li::after { 
 
    /* this is the white separator between two items */ 
 
    z-index: 1; 
 
    -webkit-transform: translateX(8px); 
 
    -moz-transform: translateX(8px); 
 
    -ms-transform: translateX(8px); 
 
    -o-transform: translateX(8px); 
 
    transform: translateX(8px); 
 
    border-left-color: #ffffff; 
 
    /* reset style */ 
 
    margin: 0; 
 
    } 
 
    .cd-breadcrumb.triangle li > *::after { 
 
    /* this is the colored triangle after each element */ 
 
    z-index: 2; 
 
    border-left-color: inherit; 
 
    } 
 
    .cd-breadcrumb.triangle li:last-of-type::after, .cd-breadcrumb.triangle li:last-of-type > *::after { 
 
    /* hide the triangle after the last step */ 
 
    display: none; 
 
    } 
 
    .cd-breadcrumb.triangle.custom-separator li::after { 
 
    /* reset style */ 
 
    background-image: none; 
 
    } 
 
    .cd-breadcrumb.triangle.custom-icons li::after, .cd-breadcrumb.triangle.custom-icons li > *::after { 
 
    /* 50px is the height of the <a> element */ 
 
    border-top-width: 25px; 
 
    border-bottom-width: 25px; 
 
    } 
 

 
    @-moz-document url-prefix() { 
 
    .cd-breadcrumb.triangle li::after, 
 
    .cd-breadcrumb.triangle li > *::after { 
 
     /* fix a bug on Firefix - tooth edge on css triangle */ 
 
     border-left-style: dashed; 
 
    } 
 
    }
<body> 
 
<section> 
 
\t <nav> 
 
\t \t <ol class="cd-breadcrumb triangle"> 
 
\t \t \t <li><a href="#0" class="checkout"><strong>Checkout</strong></a></li> 
 
      <li class="current"><a href="#0"><strong>Step 1:</strong>Account</a></li> 
 
\t \t \t <li><a href="#0"><strong>Step 2:</strong>Shipping</a></li> 
 
\t \t \t <li><a href="#0"><strong>Step 3:</strong>Payment & Place Order</a></li> 
 
\t \t \t <li><a href="#0"><strong>Step 4:</strong>Confirmation</a></li> 
 
\t \t </ol> 
 
\t </nav> 
 
</section> 
 
</body>

+0

[**此答案**](http://stackoverflow.com/questions/27636373/how-to-make-this-arrow-in- css-only/28196665#28196665)也可能帮助你。 – Harry

+0

请关注!谢谢! – OMGDrAcula

回答

2

你可以使用线性渐变:

运行在全页模式的片段,以增加或减小字体大小,而调整的窗口:)

o [R与http://codepen.io/gcyrillus/pen/aNNdyq

* { 
 
    margin: 0; 
 
    padding: 0; 
 
    -moz-box-sizing: border-box; 
 
    -webkit-box-sizing: border-box; 
 
    box-sizing: border-box; 
 
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 
 
} 
 
ol { 
 
    display:table;/* to fit to content */ 
 
    overflow:hidden;/* will hide bit arrow of last li if negative margin-right set there */ 
 
    white-space:nowrap;/* keep inline-block li on a single line */ 
 
    font-size:0.65em; 
 
} 
 
ol li { 
 
    display:inline-block;/* be an inline boxe */ 
 
    margin-top:1em; /* get some air , optionnal */ 
 
    margin-right:-1.3em;/* overlay them to reduce white gap in between. tune in em to your needs */ 
 
    line-height:1.2em; /* tune to your needs */ 
 
    padding:1em 2em;/* should be fine with gradient bg */ 
 
    background:linear-gradient(70deg, transparent 1em, lightgray 1em, lightgray 50%, transparent 50%) top left no-repeat, 
 
    linear-gradient(-110deg, transparent 1em, lightgray 1em, lightgray 55%, transparent 55%) top no-repeat, 
 
    linear-gradient(-70deg, transparent 1em, lightgray 1em, lightgray 50%, transparent 50%) bottom left no-repeat, 
 
    linear-gradient(110deg, transparent 1em, lightgray 1em, lightgray 55%, transparent 55%) bottom no-repeat; 
 
    /*bg arrow color is lightgray, to chanage it, change each one of theme in gradient */ 
 
    background-size:100% 51.5% ;/* resize each piece a gradient to draw the shape */ 
 
    
 
} 
 
ol li.current, ol li:hover { 
 
    background:linear-gradient(70deg, transparent 1em, #FF0000 1em, #FF0000 50%, transparent 50%) top left no-repeat, 
 
    linear-gradient(-110deg, transparent 1em, #FF0000 1em, #FF0000 55%, transparent 55%) top no-repeat, 
 
    linear-gradient(-70deg, transparent 1em, #FF0000 1em, #FF0000 50%, transparent 50%) bottom left no-repeat, 
 
    linear-gradient(110deg, transparent 1em, #FF0000 1em, #FF0000 55%, transparent 55%) bottom no-repeat; 
 
    /* bg arrow color is now red */ 
 
    background-size:100% 51.5% ; 
 
    } 
 
ol li.current a, ol li:hover a { 
 
    
 
    color:white; 
 
    
 
} 
 
a { 
 
    text-decoration:none; 
 
    color:orange; 
 
    text-shadow:1px 1px 1px black,-1px -1px 1px gray; 
 
    font-variant:small-caps; 
 
    font-weight:bold; 
 
    transition:0.2s; 
 
} 
 

 
@media all and (max-width:2700px) {html {font-size:50px;transition:1s;}} 
 
@media all and (max-width:2000px) {html {font-size:45px;transition:1s;}} 
 
@media all and (max-width:1600px) {html {font-size:30px;transition:1s;}} 
 
@media all and (max-width:1200px) {html {font-size:25px;transition:1s;}} 
 
@media all and (max-width:1100px) {html {font-size:22px;transition:1s;}} 
 
@media all and (max-width: 900px) {html {font-size:18px;transition:1s;}} 
 
@media all and (max-width: 700px) {html {font-size:15px;transition:1s;}} 
 
@media all and (max-width: 500px) {html {font-size:12px;transition:1s;}} 
 
@media all and (max-width: 300px) {html {font-size: 8px;transition:1s;}}
<body> 
 
<section> 
 
\t <nav> 
 
\t \t <ol class="cd-breadcrumb triangle"> 
 
\t \t \t <li><a href="#0" class="checkout"><strong>Checkout</strong></a></li> 
 
      <li class="current"><a href="#0"><strong>Step 1:</strong>Account</a></li> 
 
\t \t \t <li><a href="#0"><strong>Step 2:</strong>Shipping</a></li> 
 
\t \t \t <li><a href="#0"><strong>Step 3:</strong>Payment & Place Order</a></li> 
 
\t \t \t <li><a href="#0"><strong>Step 4:</strong>Confirmation</a></li> 
 
\t \t </ol> 
 
\t </nav> 
 
</section> 
 
</body>

+0

我能在小提琴中得到这个吗?或者我可以只复制你放在那里的CSS?动画似乎表明它的工作,但编号喜欢尝试拖动一个小提琴或钢笔的结果区域。 – OMGDrAcula

+0

@OMGDrAcula这是一个codepen与一堆mediaqueries测试:http://codepen.io/gcyrillus/pen/aNNdyq(回答更新) –

+0

太棒了!它看起来工作很好,除了我在所有div中间看到一条白线。至少在铬。 – OMGDrAcula

1

这里是一个非常简单的方法,以使其发挥,但是它使用了改造,使你的目标浏览器必须支持该属性(最先进最新的浏览器做) 。

enter image description here

body { 
 
\t padding-top: 95px; 
 
} 
 

 
.crumb-trail { 
 
\t background-color: #CCD2D8; 
 
\t color: #62717C; 
 
\t list-style: none; 
 
\t padding: 0px; 
 
\t margin: auto; 
 
\t width: 80%; 
 
} 
 

 
.crumb { 
 
\t padding: 4px 16px; 
 
\t position: relative; 
 
} 
 

 

 
.crumb:not(:last-child):before, 
 
.crumb:not(:last-child):after { 
 
\t content: ''; 
 
\t display: inline-block; 
 
\t height: 1px; 
 
\t width: 17px; 
 
\t position: absolute; 
 
\t right: -7px; 
 
\t background-color: #fff; 
 
} 
 

 
.crumb:before { 
 
\t top: 6px; 
 
\t -moz-transform: rotate(60deg); 
 
\t -ms-transform: rotate(60deg); 
 
\t -o-transform: rotate(60deg); 
 
\t -webkit-transform: rotate(60deg); 
 
\t transform: rotate(60deg); 
 
} 
 
.crumb:after { 
 
\t bottom: 6px; 
 
\t -moz-transform: rotate(120deg); 
 
\t -ms-transform: rotate(120deg); 
 
\t -o-transform: rotate(120deg); 
 
\t -webkit-transform: rotate(120deg); 
 
\t transform: rotate(120deg); 
 
}
<!DOCTYPE html> 
 
<html lang="en"> 
 
\t <head> 
 
\t \t <meta charset="utf-8"> 
 
\t \t <title>BreadCrumbs</title> 
 
\t \t <link rel="stylesheet" type="text/css" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.1/normalize.min.css"> 
 
\t \t <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> 
 
\t \t <link rel="stylesheet" type="text/css" href="breadcrumbs.css"> 
 
\t </head> 
 
\t <body> 
 
\t \t 
 
\t \t <ul class="crumb-trail clearfix"> 
 
\t \t \t <li class="crumb pull-left"> 
 
\t \t \t \t Home 
 
\t \t \t </li> 
 
\t \t \t <li class="crumb pull-left"> 
 
\t \t \t \t Forums 
 
\t \t \t </li> 
 
\t \t \t <li class="crumb pull-left"> 
 
\t \t \t \t Search page 
 
\t \t \t </li> 
 
\t \t \t <li class="crumb pull-left"> 
 
\t \t \t \t Preview: Search criteria 
 
\t \t \t </li> 
 
\t \t </ul> 
 
\t \t 
 
\t \t <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
\t \t <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
\t </body> 
 
</html>