【发布时间】:2013-06-26 09:18:55
【问题描述】:
我创建了一个纯 css 六边形,它可以在除某些 Android 浏览器之外的所有浏览器上正常呈现,例如:Galaxy Note。生成的内容创建的圆角三角形未正确渲染。
我创建了一个小提琴来显示我的代码。 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;
}
感谢所有帮助。
【问题讨论】:
-
这可能是我一段时间以来给出的最长答案,希望对您有所帮助
-
非常感谢@Juan。我希望我可以只用一个元素和生成的内容来实现它,但这会做到,我还更新了我的 Fiddle。通过一些定位,我可以使圆角工作。因为旧版浏览器不广泛支持转换。
-
@MisterMelotte 小心 :before 和 :after,它们在旧版浏览器中也没有得到很好的支持。很高兴你成功了,欢迎使用 stackoverflow
标签: android css cross-browser