dongqiao8417 2014-08-03 12:27
浏览 72
已采纳

为什么谷歌浏览器将我的页面放在窗口的中心(CSS和HTML问题)?

My simple website with a header, navigation menu, footer and few sections runs fine in all browsers except google chrome. When I launch it in Chrome, it centers the page, like squeezing at the very middle of the browser page.

Look it here

My code: .PHP:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Fatah's Homepage</title>
    <meta charset="utf-8"/>
    <link rel="stylesheet" href="design.css">

    <style type="text/css"></style>
</head>

<body>
    <div id="wrapper">
        <script type="text/javascript" src="js/scripting.js"></script>
        <script type="text/javascript" src="js/jquery.js"></script>


    <header id="top_header" >
        <h1>Welcome to my world!</h1>
    </header>

    <nav id="top_menu">
        <ul>
            <li>HOME</li>
            <li>WHO I'M</li>
            <li>GALLERY</li>
            <li>MY DIARY</li>
            <li>BLOG</li>    
        <ul>
    </nav>

<div id="new_div">
<section id="main_section">
<article>


<header>
<hgroup>
    <h1>Title of Article 1</h1>
    <h2>Subtitle of the article 1</h2>
</hgroup>
</header>

<p>This is the first best article ever</p>
<footer>
-Written by Jabir
</footer>
</article>


<article>


<header>
<hgroup>
    <h1>Title of Article 2</h1>
    <h2>Subtitle of the article 2</h2>
</hgroup>
</header>

<p>This is the second best article ever</p>
<footer>
-Written by Jabir
</footer>
</article>
</section>
</div>

<aside id="side_news">
<h4>Fatah's update</h4>
Fatah became very stupid!
</aside>

<footer id="the_footer">
Developed by Jabir Al Fatah 2014
</footer>

</div>

</body>





</html>

.CSS:

*{
margin:0px;
padding:0px;

}
h1{
font:bold 20px Tahoma;

}
h2{
font:bold 14px Tahoma;

}
header,section,footer, aside, nav, article, hgroup{
display:block;
}
body{
width:100%;
display:-webkit-box;
-webkit-box-pack:center;
}
#wrapper{
max-width:1000px;
margin:20px auto;
display:-webkit-box;
-webkit-box-orient:vertical;
-webkit-box-flex:1;

}
#top_header{
background:yellow;
border:3px solid black;
padding:20px;
}
#top_menu{
border:red;
background:blue;
color:white;
}
#top_menu li{
display:inline-block;
list-style:none;
padding:5px;
font:bold 14px Tahoma;
}
#new_div{
display:-webkit-box;
-webkit-box-orient:horizontal;
}
#main_section{

border:1px solid blue;
-webkit-box-flex:1;
margin:20px;
padding:20px;
}

#side_news{
border:1px solid red;    
width:220px;     
margin:20px 0px;
padding:30px;
background:blue;
}

#the_footer{
text-align:center;
padding:20px;
border-top: 2px solid green;
}
  • 写回答

2条回答 默认 最新

  • dongxing2710 2014-08-03 12:34
    关注

    remove the display:-webkit-box; in body ....

    body{
    width:100%;
    -webkit-box-pack:center;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)