网站定位困难



我不久前买了一个脚本,有点旧了。不管怎样,页面是向左对齐的。我对编程了解不多。我搜索了Google, YouTube和Stack Overflow来寻找我这个简单问题的答案,但是没有运气。我很确定它需要用(div)标签居中,但细节…我迷路了。请帮忙看一下。

a, a:visited, a:active {
color: #9b7e5b;
}
a.toplink, a.toplink:hover, a.toplink:visited, a.toplink:active {
color: #FFFFFF;
    font-size: 12px;
}
.forCopyright {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
    COLOR: #FFFFFF; 
text-align: center;
background-color: #B57C37;
}
a.forCopyright {
text-decoration: underline;
}
body, td, .forTexts {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
}
a.menutxt, a.menutxt:hover, a.menutxt:visited, a.menutxt:active {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #9b7e5b;
}
.menutxt {
PADDING-RIGHT: 2px;
    PADDING-LEFT: 5px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #9b7e5b;
}
.infotxt {
PADDING-RIGHT: 5px;
    PADDING-LEFT: 5px;
font-size: 10px;
}
th {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
color: #000000;
}
.title {
font-family: Verdana, Arial, Helvetica, sans-serif;
background-image: url("images/bg.jpg");
font-size: 12px;
background-color: #FFFFFF;
    padding-bottom: 4px;
background-repeat: repeat-x;
}
.inpts {
BORDER-RIGHT: #9b7e5b 1px solid; 
    BORDER-TOP: #9b7e5b 1px solid; 
    FONT-SIZE: 10px; 
    BORDER-LEFT: #9b7e5b 1px solid; 
    COLOR: #000000; 
    BORDER-BOTTOM: #9b7e5b 1px solid; 
    FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; 
    BACKGROUND-COLOR: #ffffff
}
.sbmt {
BORDER-RIGHT: #9b7e5b 1px solid; 
    BORDER-TOP: #9b7e5b 1px solid; 
    FONT-SIZE: 10px; 
    BORDER-LEFT: #9b7e5b 1px solid; 
    COLOR: #000000; 
    BORDER-BOTTOM: #9b7e5b 1px solid; 
    FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; 
    BACKGROUND-COLOR: #DEC8AD; 
}
a.hlp, a.hlp:active, a.hlp:visited, a.hlp:hover {
font-family: verdana;
font-size: 12px;
color: black;
text-decoration: none;
cursor: help;
}
.line {
background-color: #B57C37;
}
.bgcolorleft {
background-color: white;
}
.bgcolormain {
background-color: white;
}
.bgcolorright {
background-color: white;
}
div.framebody {
text-align: center;
}
div.main {
text-align: center;
margin: 0 auto; 
 }
td.inheader {
background-image: url("images/bg.jpg"); 
background-color: white;
font-weight: bold;
text-align: center; 
    padding-left: 2px;
    padding-right: 2px;
    padding-top: 2px;
    padding-bottom: 4px;
background-repeat: repeat-x;
}
td.item {
background-color: E2B176;   
text-align: center; 
}
h3 {
COLOR: #664422; 
    FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
text-align: center;
}
.calendartable {
background-color: #664422;
text-align: center;
}
.calendartablebg {
background-color: white;
}
.calendarweek {
background-color: #664422;
color: #FFFFFF;
text-align: center;
}
td.gray {
    color: gray;
}

你可以尝试创建一个容器div来包裹你的整个身体。像这样:

<body>
  <div class="container">
  ...
  ...Your Website Code...
  ...
  </div> <!-- end container -->
</body>

然后在你的css中:

.container {
  width: 950px;
  margin: 0 auto;
}

没有HTML很难确定,但我猜你需要div.main:

的宽度
div.main {
  text-align: center;
  margin: 0 auto; 
  width: 960px;
}

我相信"Main"div是你想居中的。你需要在这里定义宽度。

div.main {
text-align: center;
margin: 0 auto; 
width:90%;
 }

div.main {
text-align: center;
margin: 0 auto; 
width:1000px;
 }

如果你想让div的内容与中心对齐,使用CSS属性:

text-align:center;

如果你想让容器div对齐到中心,那么给它一个宽度并使用CSS属性margin:0 auto;

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

最后,如果没有工作,你使用positon:relative;作为父元素,然后子元素应该有一个position:absolute;top:XXpx; left:XXpx;

请务必阅读一些基本的CSS在这里。但也不要忽略这个链接

最新更新