如果我需要#element-one
是上述#element-two
,#element-two
是上述#element-three
,並且#element-three
將高於#element-one
,有沒有辦法用CSS來做到這一點?任何其他方式?有沒有辦法做一個z-索引圈?
7
A
回答
2
我不知道有什麼方法來做到這一點在CSS或JavaScript ..
我將一個元素分成兩個部分,沒有它是由用戶察覺。 (實際上這是不可能在任何情況下,例如使用文本框,但它的圖像效果很好。)
所以#element-one-part-A
高於#element-two
,#element-two
高於#element-three
,並且#element-three
高於#element-one-part-B
。從技術上講,這不是一個Z-索引圈,但它看起來像。
1
這是不可能的。 z-index與photoshop層相似,該值恰好位於堆棧中的位置。
你可以嘗試用一些javascript作弊嗎?
請參見本例用4個元素
<html>
<body>
<div id="container">
<div id="e1" class="common">
this is element 1
this is element 1
this is element 1
</div>
<div id="e2" class="common">
this is element 2
this is element 2
this is element 2
</div>
<div id="e3" class="common">
this is element 3
this is element 3
this is element 3
</div>
<div id="e4" class="common">
this is element 4
this is element 4
this is element 4
</div>
</div>
<style>
html { font-size: 3em;}
.common {
position: absolute;
overflow: hidden;
}
.clone {
color: red;
margin-top: -100%;
background-color: rgba(200, 0, 100, .5) !important;
}
.window {
overflow: hidden;
width: 50%;
height: 50%;
position: absolute;
bottom: 0;
left: 0;
background-color: rgba(0,0,0, .2);
}
#container {
width: 600px;
height: 600px;
margin: auto;
background: #eee;
position: relative;
}
#e1 {
background: yellow;
color: orange;
width: 100px;
height: 500px;
top: 50px;
left: 100px;
}
#e2 {
background: lightblue;
color: blue;
width: 500px;
height: 100px;
top: 100px;
left: 50px;
}
#e3 {
background: red;
color: pink;
width: 100px;
height: 500px;
bottom: 50px;
right: 100px;
}
#e4 {
background: lightgreen;
color: green;
width: 500px;
height: 100px;
bottom: 100px;
right: 50px;
}
</style>
<script>
(function() {
var clone = document.getElementById('e1').cloneNode(true);
clone.className = 'common clone';
var view = document.createElement('div');
view.className = 'window';
view.appendChild(clone);
document.getElementById('container').appendChild(view);
})();
</script>
</body>
</html>
相關問題
- 1. 有沒有辦法做一個查詢
- 2. 有沒有辦法在Slick中創建一個聚類索引?
- 3. 有沒有辦法訪問一個向量內的索引
- 4. 有沒有辦法做> public void test <A,B,C,....,Z>(...)
- 5. 有沒有辦法做到這一點?
- 6. 有沒有辦法解決索引索引
- 7. 我有一個Z索引問題
- 8. 有沒有辦法做一個「無法檢測的,iframe代碼」
- 9. 有沒有辦法做一個「setRotation()」方法或代碼?
- 10. 有沒有辦法在Fluent nHibernate中命名唯一索引?
- 11. 有沒有辦法讓tapply處理兩個索引值(或equivilent)?
- 12. 有沒有辦法獲得多個列表python的索引?
- 13. CSS-他們怎麼做沒有絕對定位和Z-索引?
- 14. 有沒有辦法做這個查詢沒有子選擇?
- 15. 有沒有辦法將兩個mongo集合索引到ElasticSearch中的一箇中?
- 16. 有沒有辦法增強這個圈子來檢測它?
- 17. 有沒有辦法做一個異步的FindNextFile?
- 18. 有沒有辦法做一個portal_catalog保持層次結構?
- 19. mysql:有沒有辦法做一個「INSERT INTO」2表?
- 20. 有沒有辦法做一個無障礙模式?
- 21. 有沒有辦法做一個字符串。分割的空白
- 22. 有沒有辦法做一個JSP的「xcopy部署」?
- 23. 有沒有辦法在ActionScript中做一個循環範圍?
- 24. 有沒有辦法用單個查詢來做到這一點?
- 25. 有沒有辦法做一個職位在PHP
- 26. 有沒有辦法做一個.Where(function(x)x.id in [array])?
- 27. z-index沒有正確建立索引
- 28. 有沒有辦法在彈性搜索索引中設置ttl
- 29. 有沒有辦法在Azure搜索索引中「過期」項目?
- 30. SSRS 2008中有沒有辦法做HEX2DEC?
這是一個非常有趣的問題。然而,我基本上的答案是否定的,這可能是一個伎倆一點點的破解;)非常有興趣在這裏看到一個體面的答案。注意:在你的樣品中你有3個元素,這將意味着元素被旋轉?並進一步:你想要什麼CSS版本,並允許JavaScript黑客入侵? – 2011-01-09 08:51:55
我不認爲這可以做期。它需要一個元素具有多個z-index值。非常有趣的問題,但我確實認爲你需要模擬效果......你在理論上問,還是你有要求?如果後者可以發佈一個模擬版本進行檢查?謝謝! – lnrbob 2011-01-09 09:35:56