2017-09-26 112 views
0

我目前正在爲客戶端開發一個PSD(如下圖所示),並且正在尋找關於如何從JS滑塊切割特定形狀的指導。我的初始思考過程是在橫幅底部疊加CSS形狀以獲得所需的效果,如圖所示。如何從JS橫幅剪切形狀?

我想知道是否有替代方法。我在網上瀏覽過,但無法找到我想要完成的更多信息。

歡迎任何建議。先謝謝你。

cucode custom theme

+1

嘗試使用SVG圖像 –

回答

0

您還可以使用視口寬度來達到這個目的。我希望這對你有所幫助。

.box { 
 
    width: 100%; 
 
    height: 300px; 
 
    position:relative; 
 
    background: #000; 
 
} 
 

 
.box:before 
 
{ 
 
border-top:80px solid transparent; 
 
border-left: 50vw solid #fff; 
 
content: ''; 
 
position: absolute; 
 
bottom: 0; 
 
left: 0; 
 
} 
 

 
.box:after 
 
{ 
 
border-top:80px solid transparent; 
 
border-right: 50vw solid #fff; 
 
content: ''; 
 
position: absolute; 
 
bottom: 0; 
 
right: 0; 
 
}
<div class="box"></div>

+0

美麗!我不知道這甚至可能使用視圖端口寬度。 http://numberonedesigns.com/test/ –

+0

謝謝你。 : - ) –

0

你可以創建CSS夾路徑使用this工具。

一個例子是:

.container { 
 
    background-color: orangered; 
 
    width: 100%; 
 
    height: 200px; 
 
    -webkit-clip-path: polygon(100% 0%, 100% 75%, 50% 100%, 0 75%, 0 0); 
 
    clip-path: polygon(100% 0%, 100% 75%, 50% 100%, 0 75%, 0 0); 
 
}
<div class="container"></div>