4
我試圖創建,當你將鼠標懸停在鏈接之一的菜單,它顯示在背景切片圖像。我能夠使用CSS3剪切蒙版創建僅適用於Chrome的內容。剪貼蒙版爲SVG
產生這些形狀規模與瀏覽器寬度(+1百分比!)和除兩件事情做工精良的代碼:一個是該面罩不夾我需要的形狀(參見看到形狀的彩色圖像),並且它不適用於Firefox和IE。
#music_hover {
z-index: 5;
width: 100%;
height: 100%;
background: red;
-webkit-clip-path: polygon(50% 50%, 100% 50%, 100% 100%, 70% 100%);
clip-path: polygon(50% 50%, 100% 50%, 100% 100%, 70% 100%);
float: right;
position: absolute;
background: url(../music.jpg) bottom right no-repeat;
display: none;
}
現在,爲了找到支持更多瀏覽器的東西,我已經切換到SVG圖像。我已在[CodePen]中完成此操作。我當前的解決方案的問題是,當瀏覽器不是1920x1080時,切片不會「保持在一起」。第一排的三個切片粘在上面,而第二排粘到最下面,在頁面中間創建一個白色條。切片也不會縮放,因爲它們具有精確的點來繪製形狀(而不是剪切蒙版的百分比)。
HTML:
<svg version="1.1" id="novel_Position" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 773.685 540.94">
<defs>
<pattern id="novel_BG" patternUnits="userSpaceOnUse" width="100%" height="100%">
<image xlink:href="http://loiseau-noir.com/seb/novel.jpg" x="0" y="0" width="100%" height="100%" />
</pattern>
</defs>
<path d="M420,1.058H0v539.569l696.512,0.313c0.031-72.714,29.516-138.541,77.173-186.197L420,1.058z" fill="red"/>
</svg>
CSS:
#novel_Position {
z-index: 5;
width: 40.5%;
top: 0;
left: 0;
position: fixed;
}
現在,如果所有的不明確,頁面應有的功能是這樣的:
我還以爲你會更好創造這個作爲一個單一的SVG圖像,而不是試圖縫合在一起的多個SVG片段。 –
這是一個很好的問題!任何更新? –