我正試圖學習如何使用樣式在我的react-native應用程序中創建不同形狀。我遇到了下面的example(向下滾動到三角形),這將創建一個三角形。爲什麼這些css樣式在反應本機中創建三角形
這是博客用來創建三角形的代碼。
var Triangle = React.createClass({
render: function() {
return (
<View style={[styles.triangle, this.props.style]} />
)
}
})
triangle: {
width: 0,
height: 0,
backgroundColor: 'transparent',
borderStyle: 'solid',
borderLeftWidth: 50,
borderRightWidth: 50,
borderBottomWidth: 100,
borderLeftColor: 'transparent',
borderRightColor: 'transparent',
borderBottomColor: 'red'
}
我在我的應用程序驗證它,它畫一個三角形,但我不知道爲什麼上面的樣式屬性導致三角形被繪製在屏幕上。如果有的話,我應該只看到一個100像素的紅色正方形,因爲左側和右側的邊框顏色是透明的,底部邊框是紅色的,高度爲100像素,左邊框和右邊框每個都會增加50像素。
這些樣式如何在屏幕上創建一個三角形?
通過這個計算器鏈接https://stackoverflow.com/questions去/ 7073484/how-do-css-triangles-work –
[CSS三角形如何工作?](https://stackoverflow.com/questions/7073484/how-do-css-triangles-work) –