简体   繁体   English

IE中两个相邻div之间的Wierd Gap

[英]Wierd Gap between two adjacent div in IE

I am having a trouble in IE with divs. 我在使用div的IE中遇到麻烦。 Given below are two images of a set of divs viewed in FF and IE. 下面给出的是在FF和IE中查看的一组div的两个图像。

FF中的Div对齐

IE中的Div对齐

You can see a white line appearing in the place of border. 您会看到一条白线出现在边框位置。 I am creating this divs dynamically. 我正在动态创建此div。

<DIV style="WIDTH: 49px" class=ganttview-grid-row-cell sizset="36" sizcache07230265382227504="352">
<br/>
<DIV style="TEXT-ALIGN: center; WIDTH: 11px" class=ganttview-grid-row-cell-partition></DIV>
<br/>
<DIV style="TEXT-ALIGN: center; WIDTH: 11px" class=ganttview-grid-row-cell-partition></DIV>
<br/>
<DIV style="TEXT-ALIGN: center; WIDTH: 11px" class=ganttview-grid-row-cell-partition></DIV>
<br/>
<DIV style="TEXT-ALIGN: center; WIDTH: 11px" class="ganttview-grid-row-cell-partition last"></DIV><br/></DIV>

Given above is the dynamically generated code for the divs. 上面给出的是为div动态生成的代码。 The classes defined for the div are given below: 为div定义的类如下:

div.ganttview-grid-row-cell {
float: left;

/* IE problem */
position:relative;

/*top: 0;
left: 0;*/
z-index:0;

} }

div.ganttview-grid-row-cell-partition {
border-right : 1px dotted #6B6659; 
font-size: 150%;
color: black;
height: 21px;
line-height: 120%; 
float : left;   

} }

div.ganttview-grid-row-cell-partition.last {
border-right: none;
margin-right: 0px;

} }

I am having this gap in all the IE versions. 我在所有IE版本中都有这个差距。 Dont know where i am going wrong. 不知道我要去哪里错了。 I did find other questions related to this and tried all but its not working. 我确实找到了与此有关的其他问题,并尝试了所有方法,但均无法解决。 For eg 例如

1) adding 1)添加

 <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>

in head tag. 在头标签中。

2) setting position to absolute 2)将位置设置为绝对

3) setting margin padding everything to zero. 3)将边距填充全部设置为零。

Adding some more points after some testing. 经过一些测试后再增加一些点。 As said earlier these are dynamically created divs, given below is the code in jquery of how it is created. 如前所述,它们是动态创建的div,下面是jquery中如何创建它的代码。

for(var z = 1 ; z <= 4 ; z++ ) {                                                                        
                $i5MinPartition = jQuery("<div>", 
                        {   
                    "class": "ganttview-grid-row-cell-partition",
                    "css": { "width": ((cellWidth/4) - 1) + "px", "text-align": "center"} 
                        });
                if(bgData[count] && bgData[count].workloadValue >= j) {
                    $i5MinPartition.css({"background": "#669900"});
                }
                if(bgData[count] && bgData[count].scheduleAllocationValue >= j) {
                    $i5MinPartition.text('x');
                }                       
                cellDiv.append($i5MinPartition);

                count++;
            }

The cellWidth here is 50. Now i found that IE is not taking decimal values for width whereas firefox is taking it. 这里的cellWidth是50。现在,我发现IE的宽度不采用十进制值,而Firefox却采用十进制值。

The equation 等式

(cellWidth/4) - 1 (cellWidth / 4)-1

gives 11.5 in FF whereas in IE it is 11. 在FF中给出11.5,而在IE中给出11。

Please help. 请帮忙。

Thanks in advance. 提前致谢。

嗨,尝试将其添加到父元素。

font-size: 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM