一種怪異的例子,但這裏有雲:CSS - 啓用「自動展開」絕對定位的DIV當內容超出寬度/高度參數
如何獲取絕對定位的DIV當內容被插入到擴大超越其邊界?下面是代碼:
<html>
<head>
<style>
* {margin: 0; padding: 0;}
body {white-space: nowrap; text-align: center; color: white; font-size: 2em;}
div#container {position: relative; height: 100px; width: 50px;}
div#a {height: 50px; width: 25px; background-color: red; position: absolute; top: 0; left: 0;}
div#b {height: 50px; width: 25px; background-color: blue; position: absolute; top: 0; right: 0}
div#c {height: 50px; width: 25px; background-color: orange; position: absolute; bottom: 0; left: 0;}
div#d {height: 50px; width: 25px; background-color: purple; position: absolute; bottom: 0; right: 0;}
span#title {position: relative; overflow: visible}
</style>
</head>
<body>
<div id="container">
<div id="a"><span id="title">This is my title</span></div>
<div id="b">B</div>
<div id="c">C</div>
<div id="d">D</div>
</div>
</body>
在上面的例子中,DIV內容「a」被隱藏(由於寬度/高度限制)。如果我們將其設置爲「min-height」和「min-width」,則內容位於其他div的「後面」,但不會移動它們。我怎樣才能做到這一點?
注意:我試圖弄清楚這一點,因爲我需要「重新定位」DIV在HTML中排序的順序(我試圖在Wordpress中製作子模板)。任何示例/資源都非常感謝。
乾杯, Sapiensgladio
如果您需要重新定位真正改變事物的div順序,您最好使用jQuery解決方案重新排列元素。 – BumbleB2na