經過一段時間尋找解決方案後,我想出了一個。我想要做的是在第一個li
元素的top left
角落創建一個對角邊框..我嘗試使用涉及background
屬性的解決方案,但它並沒有給我完全我想要的。此外,它不允許對後面將需要的顏色進行任何處理。創建對角邊框半徑
淺藍色應該是被切割的邊框(而不是被切割的背景),深灰色應該是li
的背景。
我該如何通過CSS來實現? JS/Jquery解決方案也可以。
編輯:看到了很多誤解的回答我的問題後,我會澄清了一點:
左圖是我現在,正確的形象應該是結果。
.cal-scheme {
width: 100%;
li {
width: calc(100%/6);
height: 150px;
margin: 0;
padding: 0;
border: $thin-blue;
box-sizing: border-box;
float: left;
&:first-child {
background: linear-gradient(135deg, transparent 20px, $light-blue 0);
border: 0;
}
}
}
如何是你的邊界(lightblue)內的背景(darkgrey)? –
@BogdanKuštan事實並非如此。我將背景燈變成藍色,以便您可以看到背景爲深灰色的問題。 – Chrillewoodz
這不可能通過'border-radius'實現,但是對這個屬性的一個提議的增強將允許你做你正在尋找的東西(搜索「css corner shape」)。與此同時,將這種效果應用於邊界將會有些不平凡。關於以這種方式倒角無邊界背景有許多問題,BogdanKuštan的答案中顯示了一個解決方案,但我不確定是否存在邊界。 – BoltClock