如果它是空的,是否有可能保持跨度的宽度?
我有以下HTML伪表:
<p><span class="col1">Day:</span><span class="col2"><?PHP echo somePHP ?></span></p> <p><span class="col1">Time:</span><span class="col2"><?PHP echo somePHP ?></span></p> <p><span class="col1">Class:</span><span class="col2"><?PHP echo somePHP ?></span></p> <p><span class="col1">Teacher:</span><span class="col2"><?PHP echo somePHP ?></span></p>
使用CSS:
span.col1 {width: 100px;float: left;} span.col2 {width: 100px;}
有时,在col2中回显的PHP是空的,当这种情况发生时,col2的宽度为0,col1在下面的段落,它最终堆叠在上面的段落col1旁边.