Q
重疊的相同元素
2
A
回答
3
您可以簡單地定義一組元素,它具有指定的大小,display: inline-block
要顯示在一行中並且負右邊距要重疊。
以下是一個簡單的HTML/CSS示例來解決您的問題。當然,您必須將其移植到您的React Native應用程序中。
.a {
display: inline-block;
height: 50px;
width: 50px;
margin-right: -20px;
background: gray;
border-radius: 50%;
border: 2px solid white;
box-shadow: 0 8px 15px #999;
}
<div class="a"></div>
<div class="a"></div>
<div class="a"></div>
<div class="a"></div>
<div class="a"></div>
0
最簡單的(不是最好的方法)會是這樣的。 如果你使用預處理器,你可以寫這個DRYer。
ul {
padding: 20px 0;
list-style: none;
clear: both;
}
.item {
float: left;
position: relative;
}
.item img {
border-radius: 50%;
overflow: hidden;
position: relative;
}
.item:nth-child(1) img {
background: #aaa;
border-radius: 50%;
}
.item:nth-child(2) img {
background: #bbb;
left: -20px;
}
.item:nth-child(3) img {
background: #ccc;
left: -40px;
}
.item:nth-child(4) img {
background: #ddd;
left: -60px;
}
<ul>
<li class="item"><img src="" width="50" height="50"></li>
<li class="item"><img src="" width="50" height="50"></li>
<li class="item"><img src="" width="50" height="50"></li>
<li class="item"><img src="" width="50" height="50"></li>
</ul>
0
您可以使用相同樣式的所有元素,因爲當我們與柔性方向列:「行」,第一個元素會被放置在一排開始。
請勿使用負邊距!它可能不適用於IOS。
接下來,您應該記住,在反應本機中,每個下一個元素都將在前一個元素之上。所以你唯一應該做的就是在小塊內部進行圖像定位。
+0
爲什麼你降低我的答案?你看到標籤'反應原生'和'反應原生樣式表'嗎?這不是關於網絡。這完全是關於移動開發。使用html代碼片段的答案不正確! –
相關問題
- 1. 同位素元素重疊
- 2. 同位摺疊(元素重疊)
- 3. 在relativeLayout中相互重疊的元素
- 4. div元素互相重疊-css
- 5. 旋轉元素互相重疊
- 6. 相關元素與Chrome中的絕對元素重疊
- 7. HTML元素重疊
- 8. 重疊CSS元素
- 9. HTML元素重疊
- 10. 重疊HTML元素
- 11. Div重疊元素
- 12. 如何完美重疊兩個(相同)元素?
- 13. 重疊元素中的目標元素
- 14. HTML&jQuery - 需要重疊重疊元素
- 15. svg元素層/重疊/疊加/疊加
- 16. 重疊的元素設計
- 17. 帶重疊元素的XSLT?
- 18. 重疊的XAML元素
- 19. 的ListView重疊元素
- 20. 重疊的HTML元素
- 21. 重疊的盒子元素
- 22. Flexpaper重疊的HTML元素
- 23. 相對定位的div重疊 - 共享相同的像素行
- 24. 畫布重疊元素
- 25. CSS菜單重疊元素
- 26. HTML 5元素重疊
- 27. 重疊元素 - HTML,CSS
- 28. 覆蓋/重疊元素
- 29. 塊級元素重疊
- 30. 重疊元素錯誤
React-native(請參閱問題標籤)不支持標準的web html和css。 –
@AlexBelets OP沒有提供代碼,所以我決定給出一個簡單的例子,說明基本樣式(OP明確要求的樣式)的樣子。當答案被接受時,我認爲,這就是所需要的。 但無論如何您的意見,相應地更新我的答案。 – andreas