<div style="height:42px; width:100%; margin:0; padding:0">
<div style="float:left;margin:0; padding:0;"><img src="/images/content_title_01.jpg" width="23" height="42" alt=""></div>
<div style="float:left;margin:0 ; padding:7px 0 0 0;height:42px; width:765px; background: url('/images/content_title_02.jpg') repeat-x; "><?php echo $this->escape($this->item->title); ?>
</div>
<div style="float:left;margin:0; padding:0;"><img src="/images/content_title_04.jpg" width="22" height="42" alt=""></div>
</div>
需改為以下,注意float變成一左一右,然後主內容在中間:
<div style="height:42px; width:100%;">
<div style="float:left;width:23px"><img src="/images/content_title_01.jpg" width="23" height="42" alt=""></div>
<div style="float:right;width:22px"><img src="/images/content_title_04.jpg" width="22" height="42" alt=""></div>
<div style="display:block; margin-left:auto; margin-right: auto;padding:7px 0 0 0;height:42px; background: url('/images/content_title_02.jpg') repeat-x; "><?php echo $this->escape($this->item->title); ?></div>
</div>
中間的文字區域就可以動態延長寬度。用於中間文字區域的要有背景時。
測試過IE 7/8/9, Firefox, Chrome都ok。這個解法的來源是:
http://stackoverflow.com/questions/1359025/css-layout-dynamic-width-div |