本文介绍了谁不能加起来,我还是Internet Explorer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图提高我对CSS的理解,并创建了一个非常简单的页面,页脚和三列的简单页面。这看起来就像我在FF和Opera中预期的一样,但是(惊喜)在IE中给出了一个问题




您可以在


如果查看源代码,您会看到用于创建列的三个div用于创建列名称为col1 ,col2和col3。


为了获得相等宽度的三列,在它们之间有一点

空间,我让三个div有每个宽度为30%,

左右填充为1%。最初,他们都剩下零和

右边距。通过我的学生数学,这使每个div 32%宽。三个

div,每个32%,96%,留下我4%的空间我希望在col1和col2之间以及col2和col3之间留下



因此,我向col2添加了2%的左右边距,这整齐地加到了
100%并且在另外两个中间留下了col2 smack。


所有这些在FF和Opera中运行良好,但在IE中,右栏

下降,大概是因为IE认为整体宽度

三者超过100%,因此将col3向下移动。我想要什么

才知道为什么IE会这么想?我通过给出

col2的左右边距1.8%来解决这个问题,但这意味着在FF

和Opera中,中间位置略微进一步中心的左边。

奇怪的是(或许没有),IE把它放在中间。


有什么解释吗? TIA


免责声明:我知道从语义上来说,col1,col2和col3都是

不是div的好名字,因为它们反映了一个表现方面,而不是

a语义一。他们在这里使用它们,因为我正在尝试CSS,所以

想要确保我知道哪个是哪个。我保证不会在真实页面上这样做

!!


-

Alan Silver

(此行下面添加的任何内容都与我无关)

I was attempting to improve my understanding of CSS, and created a very
simple page with a header, footer and three columns. This looked just
like I expected in FF and Opera, but (surprise surprise) gave a problem
in IE.

You can see the page at http://www.kidsinaction.org.uk/3cols.html

If you look at the source, you will see that the three divs used to
create the columns are imaginatively named col1, col2 and col3.

In an attempt to get the three columns of equal width, with a little
space between them, I made the three divs have a width of 30% each, with
left and right padding of 1%. Initially, they all had zero left and
right margin. By my schoolboy maths, this makes each div 32% wide. Three
divs at 32% each makes 96%, leaving me 4% for the space I wanted to
leave between col1 and col2, and between col2 and col3.

Thus, I added 2% left and right margin to col2, which adds up neatly to
100% and leaves col2 smack in the middle of the other two.

All of this works fine in FF and Opera, but in IE, the right column
dropped down, presumably because IE thought that the overall width of
the three was more than 100%, so moved col3 downwards. What I would like
to know is why IE thought this? I worked around the problem by giving
col2 a left and right margin of 1.8% instead, but this means that in FF
and Opera, the middle col is slightly further to the left of centre.
Oddly enough (or maybe not), IE puts it right in the middle.

Any explanation? TIA

Disclaimer: I know that semantically speaking, col1, col2 and col3 are
not good names for the divs as they reflect a presentational aspect, not
a semantic one. They were used here as I was experimenting with CSS, so
wanted to ensure that I knew which was which. I promise not to do this
on a real page!!

--
Alan Silver
(anything added below this line is nothing to do with me)

推荐答案





相反,你应该使用反映

内容性质的名称。这样,名称在任何地方都有意义。对于

示例,div名称如sitelinks等。总是意味着一样。如果一个CSS

文件决定将链接放在页面顶部的div中,

和另一个CSS文件将它们放在左边缘,那么'' sa

表达问题。 HTML不应该反映出来。


无论如何,谢谢你的回复。


-

Alan Silver

(此行下面添加的任何东西都与我无关)



On the contrary, you should use names that reflect the nature of the
content. That way, the names have meaning wherever they are used. For
example, a div name like "sitelinks" always means the same. If one CSS
file decides to place the links in this div across the top of the page,
and another CSS file puts them down the left margin, well that''s a
presentational issue. The HTML shouldn''t reflect that.

Anyway, thanks for the reply.

--
Alan Silver
(anything added below this line is nothing to do with me)





甚至更好:导航,内容和侧栏等等。或类似的 -

真正定义列的东西。用左表示接下来会发生什么?
一周你想把菜单移到右边?


-

-bts

-警告:我为草坪鹿刹车



Or even better: "navigation", "content", and "sidebar" or similar -
something that really defines the columns. With "left" what happens next
week when you want to move the menu to the right side?

--
-bts
-Warning: I brake for lawn deer


这篇关于谁不能加起来,我还是Internet Explorer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 00:12
查看更多