简体   繁体   English

在FF和IE9中工作的CSS中心列?

[英]CSS center column that works in FF and IE9?

I am totally a beginner at CSS layouts, but I am trying to just start a basic one that is simply a 'fixed width' center column (just one div), so that the sides are flexible. 我完全是CSS布局的初学者,但我试图刚刚开始一个基本的,只是一个“固定宽度”中心列(只有一个div),这样两边都很灵活。 I know this is not responsive/reactive, but I am just starting. 我知道这不是响应/反应,但我刚刚开始。

So I have tried googling tons of examples, but I can't find a starting point that works on both FF and IE9? 所以我试过谷歌搜索大量的例子,但我找不到适用于FF和IE9的起点? I mean just getting started and they are different?? 我的意思是刚开始,他们是不同的?

Here is latest example of simple style I tried: 这是我尝试的简单风格的最新示例:

* { padding: 0; margin: 0; }

body {
 font-family: Arial, Helvetica, sans-serif;
 font-size: 13px;
 background: #f5f5f5;
}
#wrapper { 
 margin: 0 auto;
 width: 922px;
}
#content { 
 width: 900px;
 color: #333;
 border: 0px solid #f5f5f5;
 background: white;
 margin: 0px 0px 0px 0px;
 padding: 10px;
 height: 600px;
}

so this is the very beginning but already FF shows this aligned to the center and IE doesn't. 所以这是一个开始,但已经FF显示这与中心对齐,IE没有。 So already everything I try (ie left:50% and margin-right:-461px, as an example I found) affects these differently. 所以我尝试的所有内容(即左边:50%和边距右边:-461px,我发现的例子)对这些影响不同。 I read all over the place this is a very common challege, but I fear there is some foundation logic here that I am unaware of? 我在这里读到了这是一个非常普遍的挑战,但我担心这里有一些我不知道的基础逻辑?

any help with this is greatly appreciated! 非常感谢任何帮助!

EDIT: Thanks for the comment! 编辑:感谢您的评论! I do have the following, which again works in IE (and in chrome) but not FF? 我有以下,它再次适用于IE(和铬)但不是FF吗?

css: CSS:

* { padding: 0; margin: 0; }

body {
 font-family: Arial, Helvetica, sans-serif;
 font-size: 13px;
 background: #f5f5f5;
}
#wrapper { 
 margin: 0 auto;
 width: 922px;
 margin-left:auto;
 margin-right:auto;

}
#content { 
 width: 900px;
 color: #333;
 border: 2px solid #f5f5f5;
 background: white;
 padding: 10px;
 height: 600px;
 position:absolute;
 left:50%;
 margin-left:-461px;
}

#welcomeBanner{
    text-align:center;
    font-family:"segoe ui light","segoe ui","segoe";
    font-size:18pt;
    padding-top:20px;
    padding-bottom:20px;
    margin-top:0px;
}

html: is literally only: html:只是字面上的:

    <div id="wrapper">
        <div id="content">
            <div id="welcomeBanner">Attempting to Learn This Stuff<div>
        </div>
    </div>

so in IE9 and Chrome I get the title in the center, big box center fixed with back ground color, etc. In FF nothing. 所以在IE9和Chrome中我得到了中间的标题,大盒子中心用背景颜色等固定。在FF中没什么。 I like there is not style applied to the page at all? 我喜欢没有应用于页面的样式? I am using a link tag in the head, but it is obviously there and working for the others? 我正在使用头部的链接标签,但它显然在那里,并为其他人工作?

body {
    width:100%
}

div {
    width: 900px;
    margin:0 auto;
}

should work 应该管用

cf Centering a Div in IE9 Using margin:auto cf 在IE9中居中使用margin:auto

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

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