我已經創建了一個純CSS css六邊形,它在所有瀏覽器上呈現效果都很好,除了某些Android瀏覽器(例如Galaxy Note)外。生成的內容創建的圓角三角形不能正確渲染。CSS hexagon在Android上無法正確顯示
我創建了一個小提琴來展示我的代碼。 http://jsfiddle.net/mistermelotte/r8X8c/
HTML
<span class="hexagon"></span>
CSS
.hexagon {
position: relative;
margin: 1em auto;
width: 80px;
height: 55px;
border-radius: 5px;
background: #a0d1e6;
display: block;
}
.hexagon:before {
position: absolute;
top: -19px;
left: 0;
width: 0;
height: 0;
border-right: 40px solid transparent;
border-bottom: 20px solid #a0d1e6;
border-left: 40px solid transparent;
border-radius: 5px;
content:"";
}
.hexagon:after {
position: absolute;
bottom: -19px;
left: 0;
width: 0;
height: 0;
border-top: 20px solid #a0d1e6;
border-right: 40px solid transparent;
border-left: 40px solid transparent;
border-radius: 5px;
content:"";
}
.lt-ie9 .hexagon:before {
top: -20px;
}
.lt-ie9 .hexagon:after {
bottom: -20px;
}
所有幫助表示讚賞。
您可以參考此鏈接http://css-tricks.com/examples/ShapesOfCSS/ – Narendra
這可能是我在一段時間內給出的最長的答案,希望它可以幫助 –
非常感謝@Juan。我希望我可以用一個元素和生成的內容來實現它,但是這樣做,我也更新了我的小提琴。通過一些定位,我可以使圓角工作。因爲舊版瀏覽器沒有廣泛支持轉換。 –