我有三个div并排放置(在显示器上),每个div都有一个背景图像(通过CSS)和漂浮在每个背景上的文本(通过html)。这三个div由一个容器div包围,它在页面上以三个为中心。我希望这些div在移动设备上查看时垂直堆叠。有什么建议?这是测试页面:http://worddiva.com.s40758.gridserver.com/?page_id=649
这是html (CSS在下面):
<div style="margin: 0 auto; width:744px;">
<div style="float: left; width: 248px;">
<div id="parchment">
<img id="parchmentbg" src="http://worddiva.com.s40758.gridserver.com/wp-content/uploads/2014/07/Parchment-Grade-Orange.png"/>
<p id="text">
<span class="storytellingorange"><strong>Editorial</strong></span>
– Credit Union
– Wine & Travel
– Arts & Letters
– Alternative Energy
</p>
</div>
</div>
<div style="float: left; width: 248px;">
<div id="parchment">
<img id="parchmentbg" src="http://worddiva.com.s40758.gridserver.com/wp-content/uploads/2014/07/Parchment-Grade-Orange.png"/>
<p id="text">
<span class="storytellingorange"><strong>Editorial</strong></span>
– Credit Union
– Wine & Travel
– Arts & Letters
– Alternative Energy
</p>
</div>
</div>
<div style="float: left; width: 248px;">
<div id="parchment">
<img id="parchmentbg" src="http://worddiva.com.s40758.gridserver.com/wp-content/uploads/2014/07/Parchment-Grade-Orange.png"/>
<p id="text">
<span class="storytellingorange"><strong>Editorial</strong></span>
– Credit Union
– Wine & Travel
– Arts & Letters
– Alternative Energy
</p>
</div>
</div>
</div>
这是CSS:
#parchment
{
height:133px;
width: 744px;
position:relative;
margin-left: auto;
margin-right: auto;
}
#parchmentbg
{
position:absolute;
left:0;
top:0;
}
#text
{
z-index:100;
position:absolute;
line-height: 1.3em;
left:10px;
top:-15px;
}
答案 0 :(得分:0)
#parchment
的父div具有固定宽度。这会导致子div不会相互堆叠,因为父div不会变小。