IE下面网页居中显示的问题_html/css_WEB-ITnose
ie 居中
页面在Chrome和FF下是居中的,但在IE各个版本下面都是靠左显示的,<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
.center{margin:0px auto;}
这两个都加上了,请问各位大侠还有什么需要注意的地方?
回复讨论(解决方案)
body, html{width:100%;height:100%;}
.center{margin:0px auto;}
body, html{width:100%;height:100%;}
.center{margin:0px auto;}
加上了第一句了,还是不行啊!
相关CSS文件如下:
/*---------- base ---------*/
*{padding:0px;margin:0px;}
html{background:#FFF;}
body{font:12px Verdana,Arial,Tahoma; line-height: 1.8em; color:#999999;}
img{border:none;}
button {
border: 1px solid #CCCCCC;
padding: 5px;
cursor:pointer;
}
a{color:#666666;text-decoration:none;}
a:hover{ background-color:#8D900B; color:#ffffff}
.header a:hover,.pagelist a:hover,.favorite a:hover,.pic a:hover,a.pic:hover{ color:#8D900B; background-color:#ffffff}
ul,li{list-style:none;}
input,select,button{font:12px Verdana,Arial,Tahoma;vertical-align:middle;}
h1, h2, h3, h4, h5, h6 {font-family: "Microsoft YaHei";font-size: 100%;font-weight: normal;}
/*---------- stock ---------*/
.center{margin:0px auto;}
.w960{width:960px;}
.wrapbox {margin: 0 auto;width: 960px;clear:both;}
.mainbox{ width:630px; float:left; overflow:hidden}
.sidebox{ width:300px; float:right; overflow:hidden}
.fl{ float:left}
.fr{ float:right}
.mt1{margin-top:8px;}
.mt2{margin-top:16px;}
.clear{overflow:hidden; clear:both; height:1px; line-height:1px;}
.fs-12{font-size:12px;}
.fc-f60{color:#F60;}
.fc-f90{color:#F90;}
.clr{clear:both;}
.ipt-txt{line-height:15px;padding:4px 5px;border-width:1px;border-style:solid;border-color:#ccc;font-size:12px;margin-right:2px;}
.nb{line-height:20x;padding:1px 2px;border-width:1px;border-style:solid;border-color:#666 #BBB #BBB #666;font-size:12px;margin-right:2px}
.btn-1{padding: 0px;width:56px;height:24px;border:none;background:url(../images/comm-bt.gif) no-repeat;line-height:25px;letter-spacing:1px;cursor:pointer;overflow:hidden;color:#585858;}
.btn-2{width:70px;height:25px;border:none;background:url(../images/btn-bg2.gif) left top no-repeat;line-height:25px;overflow:hidden;color:#444;margin-right:2px;cursor:pointer;}
.header{width:100%;overflow:hidden; margin-bottom: 10px;}
.header_top{background: url("../images/topbar.png") repeat-x scroll 0 -8px transparent;clear: both;height: 28px;line-height:26px;}
.header_top .welcome{float:left;padding-left:10px;height:26px;line-height:26px; }
.header_top a.rss{}
.header_top .toplinks{ float:right;height:26px;line-height:26px;}
.header_top .toplinks a{margin:0 2px;}
.header_top .toplinks span{margin-left:15px;}
.header .top{ /**background:url("../images/line.gif") repeat-x scroll left bottom transparent;**/ border-bottom:1px solid #FAEFE3; height:96px;position: relative;overflow: hidden;}
.logo {height: 85px;width:345px;position:absolute;left:0;top:0}
.logo h1 a {background: url("../images/logo.gif") no-repeat scroll 0 0 transparent;display: block;height: 85px;overflow: hidden;text-indent: -9999em;width: 345px;}
.hi{ float:left}
.userface{ float:right; margin-top:5px;}
.userface img{ border:1px solid #dddddd; padding:1px;}
.userface a:hover{ background:none;}
.userface a:hover img{ border:1px solid #8D900B}
.mylink{ float:left}
.mylink li{ float:left}
把你的HTML的完整代码贴上来呀
要不然你试试这个:
body{ text-align:center; }
.center{ margin:0 auto; text-align:left; }
要不然你试试这个:
body{ text-align:center; }
.center{ margin:0 auto; text-align:left; }
这个倒是居中了,但所有文本也居中了
再为不需要居中的设置text-align:left;不就行了?
很多标签啊,都要设岂不是太麻烦了?
很多标签啊,都要设岂不是太麻烦了?
你把完整的HTML代码贴出来呀,你之前贴的不完整
引用 8 楼 crazyzyc 的回复:很多标签啊,都要设岂不是太麻烦了?
你把完整的HTML代码贴出来呀,你之前贴的不完整
这个是Header.html的代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">=$headtitle?> =$headmeta?>=$cache_settings['headcontent']?>
哦,你这个代码里找不到.center啊,
估计应该是由JS或PHP动态生成的。
你能把动态生成的代码贴上来吗?(可以通过浏览器的开发者工具得到动态生成的HTML)
刚看了下,浏览器的浏览源文件里也没有.center,我把.center改成 body,还是不行,应该改哪里啊?
你到底要哪部分居中?至少哪个要居中的DIV,要设置width比如996px,然后加margin:0 auto;要不全部都默认width 100%,当然不会居中罗。
相对文件必须要有个宽度

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

WebDevelovermentReliesonHtml,CSS和JavaScript:1)HTMLStructuresContent,2)CSSStyleSIT和3)JavaScriptAddSstractivity,形成thebasisofmodernWebemodernWebExexperiences。

HTML、CSS和JavaScript在Web開發中的作用分別是:1.HTML定義網頁結構,2.CSS控製網頁樣式,3.JavaScript添加動態行為。它們共同構建了現代網站的框架、美觀和交互性。

HTML的未來趨勢是語義化和Web組件,CSS的未來趨勢是CSS-in-JS和CSSHoudini,JavaScript的未來趨勢是WebAssembly和Serverless。 1.HTML的語義化提高可訪問性和SEO效果,Web組件提升開發效率但需注意瀏覽器兼容性。 2.CSS-in-JS增強樣式管理靈活性但可能增大文件體積,CSSHoudini允許直接操作CSS渲染。 3.WebAssembly優化瀏覽器應用性能但學習曲線陡,Serverless簡化開發但需優化冷啟動問題。

HTML的未來充滿了無限可能。 1)新功能和標準將包括更多的語義化標籤和WebComponents的普及。 2)網頁設計趨勢將繼續向響應式和無障礙設計發展。 3)性能優化將通過響應式圖片加載和延遲加載技術提升用戶體驗。

HTML、CSS和JavaScript在網頁開發中的角色分別是:HTML負責內容結構,CSS負責樣式,JavaScript負責動態行為。 1.HTML通過標籤定義網頁結構和內容,確保語義化。 2.CSS通過選擇器和屬性控製網頁樣式,使其美觀易讀。 3.JavaScript通過腳本控製網頁行為,實現動態和交互功能。

HTML是構建網頁結構的基石。 1.HTML定義內容結構和語義,使用、、等標籤。 2.提供語義化標記,如、、等,提升SEO效果。 3.通過標籤實現用戶交互,需注意表單驗證。 4.使用、等高級元素結合JavaScript實現動態效果。 5.常見錯誤包括標籤未閉合和屬性值未加引號,需使用驗證工具。 6.優化策略包括減少HTTP請求、壓縮HTML、使用語義化標籤等。

HTML的作用是通過標籤和屬性定義網頁的結構和內容。 1.HTML通過到、等標籤組織內容,使其易於閱讀和理解。 2.使用語義化標籤如、等增強可訪問性和SEO。 3.優化HTML代碼可以提高網頁加載速度和用戶體驗。

HTMLISNOTAPROGRAMMENGUAGE; ITISAMARKUMARKUPLAGUAGE.1)htmlStructures andFormatSwebContentusingtags.2)itworkswithcsssforstylingandjavascript for Interactivity,增強WebevebDevelopment。
