2016-10-25 18 views

回答

1

您可以使用純CSS實現相同的結果。

  • 使用容器元素的背景顏色和圖像
  • 使用僞元素::after用白右邊框模仿右邊緣
  • 使用相同的類.tile的一些div與transform: skewX(-10deg);模仿條紋並讓他們float: right;

的Et瞧:

.container { 
 
    height: 300px; 
 
    width: 400px; 
 
    background: linear-gradient(rgba(219, 41, 117, 0.6), rgba(219, 41, 117, 0.6)), url(https://i.stack.imgur.com/e11Va.jpg); 
 
    background-size: cover; 
 
    color: white; 
 
    position: relative; 
 
    padding-right: 26px; 
 
} 
 
.container::after { 
 
    content: ""; 
 
    position: absolute; 
 
    display: block; 
 
    right: 0; 
 
    bottom: 0; 
 
    height: 0; 
 
    width: 0; 
 
    border: none; 
 
    border-left: none; 
 
    border-right: 52px solid white; 
 
    border-top: 300px solid transparent; 
 
    border-bottom: none; 
 
} 
 
.tile { 
 
    width: 30px; 
 
    height: inherit; 
 
    background: rgba(0, 0, 0, 0.6); 
 
    border-left: 5px solid white; 
 
    transform: skewX(-10deg); 
 
    float: right; 
 
}
<div class="container"> 
 
    <div class="tile"></div> 
 
    <div class="tile"></div> 
 
    <div class="tile"></div> 
 
</div>

當然,你可以添加內容到容器。只需在容器內使用另一個div,並給它適當的寬度。

+0

不客氣,很高興我能幫到你! – andreas

+0

只是一個小問題:我在這裏使用了你的技巧http://mijnwebsitebestellen.be/index.php。現在,當您將鼠標懸停在「活動地點」上時,您可以看到圖像暫時不會傾斜。我使用jQuery來動畫元素的寬度。有沒有一個quickfix這個? – Jacob

+0

如果您有其他問題,請提出另一個問題... – andreas