论坛首页 Web前端技术论坛

ie下画1px高横线只能用<table>?

浏览 19845 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2006-04-13  
CSS
css的问题发这里可以不?

我css实在是不行。

ie 下div高度我不知道怎么调到1px,好像最少是2px;如下
<div style="width:100px;height:1px;font-size:0px;border:0px;margin:0px;padding:0px;background:#000000"></div>
我只能这样实现,现在
<div style="width:1px;height:300px;background:#000000"></div>
<table cellpadding="0" cellspacing="0" style="width:100px;height:1px;background:#000">
<tr>
<td></td>
</tr>
</table>
   发表时间:2006-04-13  
<div style="width:100px;height:1px;background:#000000;overflow:hidden"></div>

PS:为什么不用border样式呢?
0 请登录后投票
   发表时间:2006-04-13  
我就是画一条线,你给点css我试下,要ff ie都行的


margin padding border我都不敢用,老是出现布局不兼容
0 请登录后投票
   发表时间:2006-04-13  
我上面写的那个就可以,ie,ff都行。

另外,这个是用border定的:
<div style="width:100px;height:0px;overflow:hidden;border-bottom:1px solid black;"></div>
0 请登录后投票
   发表时间:2006-04-13  
alin_ass 写道
我就是画一条线,你给点css我试下,要ff ie都行的


margin padding border我都不敢用,老是出现布局不兼容


<hr size="1" /> 可以满足吗?
0 请登录后投票
   发表时间:2006-04-14  
todd_lee 写道
<div style="width:100px;height:1px;background:#000000;overflow:hidden"></div>

PS:为什么不用border样式呢?



嗯,为什么一拿掉overflow:hidden,ie就变成12像素了.....
0 请登录后投票
   发表时间:2006-04-14  
alin_ass 写道
todd_lee 写道
<div style="width:100px;height:1px;background:#000000;overflow:hidden"></div>

PS:为什么不用border样式呢?



嗯,为什么一拿掉overflow:hidden,ie就变成12像素了.....
ie默认里面是有文字的。你肯定定义了页面的文字大小是12px。

加上overflow,就可以不管里面有什么东西,只要超出容器大小就隐藏掉。
0 请登录后投票
   发表时间:2006-04-14  
我们的美工最喜欢用1px*1px的gif图片了,然后设置<img>的宽高。
0 请登录后投票
   发表时间:2006-04-14  
todd_lee 写道
alin_ass 写道
todd_lee 写道
<div style="width:100px;height:1px;background:#000000;overflow:hidden"></div>

PS:为什么不用border样式呢?



嗯,为什么一拿掉overflow:hidden,ie就变成12像素了.....
ie默认里面是有文字的。你肯定定义了页面的文字大小是12px。

加上overflow,就可以不管里面有什么东西,只要超出容器大小就隐藏掉。


a~~~o
0 请登录后投票
   发表时间:2006-05-11  
很简单的:
<div style="background:#000;height:1px;width:100%;border:0;margin:0;padding:0;font-size:0;line-height:0;"></div>
这个font-size和line-height不止在ie在其它浏览器下也是继承body的,所以没有文字的元素需要定义消除它后才能定义比较小的高度。
0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics