2016-04-29 64 views
0

我有下面的代碼創建在頁面的頂部和底部的三角形div屏蔽掉三角格

#arrowdown, #arrowup { 
 
    display: block; 
 
    position: fixed; 
 
    left: 0; right: 0; 
 
    width: 0; height: 0; 
 
    margin: 0 auto; 
 
    border-left: 55px solid transparent; 
 
    border-right: 55px solid transparent; 
 
    z-index: 20; 
 
} 
 

 
#arrowdown { 
 
    bottom: 0; 
 
    border-bottom: 55px solid rgba(250,250,250,0.75); 
 
} 
 

 
#arrowup { 
 
    top: 0; 
 
    border-top: 55px solid rgba(250,250,250,0.75); 
 
} 
 

 
#arrowdown .icn, #arrowup .icn { 
 
    display: block; 
 
    position: absolute; 
 
    left: -18px; 
 
    color: #000; 
 
    text-align: center; 
 
    padding: 10px; 
 
    z-index: 25; 
 
} 
 

 
#arrowdown .icn {bottom: -52px;} 
 
#arrowup .icn {top: -52px;}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.1/css/font-awesome.css" rel="stylesheet"/> 
 

 

 
<button id="arrowup"> 
 
    <i class="icn fa fa-chevron-up fa-2x"></i> 
 
</button> 
 

 
<button id="arrowdown"> 
 
    <i class="icn fa fa-chevron-down fa-2x"></i> 
 
</button>

這將創建與icn S的內部的三角形。我想要三角形透明(現在是白色),外面有2pt的藍色邊框。我發現的例子把一個元素放在另一個元素的頂部,這將不起作用,因爲它會通過頂部透明度看到。

回答

0

mix-blend-mode可以幫助你,如果IE沒有介意。

https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/mix-blend-mode

button { 
 
    /* reset */ 
 
    background:white; 
 
    border:none; 
 
    /* prepare */ 
 
    color:white; 
 
    /* make a CSS stroke */ 
 
    text-shadow:0 0 2px blue,0 0 2px blue,0 0 2px blue,0 0 2px blue,0 0 2px blue,0 0 2px blue;/* increase numbers of shadow to erase the blur effect */ 
 
    /* do blend it */ 
 
    mix-blend-mode:multiply; 
 
} 
 
/* show transparency */ 
 
body { 
 
    background:linear-gradient(45deg,lime,turquoise,gray,purple,tomato) yellow; 
 
    background-size:450px 450px; 
 
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet"/> 
 
<button id="arrowdown"> 
 
    <i class="icn fa fa-chevron-down fa-2x"></i> 
 
</button><button id="arrowup"> 
 
    <i class="icn fa fa-chevron-up fa-2x"></i> 
 
</button> 
 

 
<button id="arrowdown"> 
 
    <i class="icn fa fa-chevron-down fa-2x"></i> 
 
</button><button id="arrowup"> 
 
    <i class="icn fa fa-chevron-up fa-2x"></i> 
 
</button> 
 

 
<button id="arrowdown"> 
 
    <i class="icn fa fa-chevron-down fa-2x"></i> 
 
</button>

SVG將做或用alt屬性基本PNG圖像。