CSS - 宽度不在span标记上 [英] CSS - width not honored on span tag

查看:106
本文介绍了CSS - 宽度不在span标记上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我的一个跨度。请考虑以下样式:

  .form_container .col1che 
{
float:left;
width:4%;
text-align:left;
}

.form_container .col2che
{
float:left;
width:80%;
text-align:left;
}

.form_container .col3che
{
float:right;
width:13%;
text-align:right;
}

我的代码中有3个跨度:

 < div class =row><! -  start:row - > 
< span class =col1che>
<?php // some db feeds?>
< / span>
< span class =col2che>
<?php // some db feeds?>
< / span>
< span class =col3che>
<?php // some db feeds?>
< / span>
< div class =clear>< / div>
< / div><! - end:row - >

当没有数据要显示在COL1CHE的,虽然我不知道)当没有数据,这个跨度崩溃,它的宽度不被尊重。这发生在Firefox,在IE它不崩溃。



我包括一个清除类,看看这是否有帮助,但没有效果。



任何想法?

解决方案

:block 不会在这里帮助你,因为当float激活时,元素会自动切换到块模式,无论其初始模式,所以你的宽度应该工作。 >

问题可能出在空的< span> 标签,可能不会呈现,因为一些晦涩的规则我不记得。您应该尝试防止您的期间为空,也许通过添加& nbsp; (如果内容为空)。


I have a issue with one of my spans. Please cosider the following styles:

.form_container .col1che
{
float: left; 
width: 4%; 
text-align: left;    
}

.form_container .col2che
{
float: left; 
width: 80%; 
text-align:left;
}

.form_container .col3che
{
float: right; 
width: 13%; 
text-align:right;
}

These 3 spans in my code:

<div class="row"><!-- start: "row" -->
     <span class="col1che">        
          <?php  //some db feeds    ?>        
     </span>
     <span class="col2che">
          <?php  //some db feeds    ?>
     </span>
     <span class="col3che">
          <?php  //some db feeds    ?>
     </span>
     <div class="clear"></div>
</div><!-- end: "row" -->

The problem occurs when there is no data to be displayed in "COL1CHE" (or maybe even in any of them although I'm not sure) when there is no data this span "collapses" and its width is not honored. This happens in Firefox, in IE it doesn't "collapse".

I included a "clear" class to see if this helps but to no avail.

Any ideas?

解决方案

display: block will not help you here because when float is activated, the elements is automatically switched to block mode, whatever its initial mode, so your width should work.

The problem may be with the empty <span> tag which might not be rendered because of some obscure rule I cannot remember. You should try preventing your span from being empty, maybe by adding a &nbsp; if the content is empty.

这篇关于CSS - 宽度不在span标记上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆