


Can anyone help enlighten me on the browser compatibility issue? I'm so annoyed. _html/css_WEB-ITnose
<html><head><meta name="keywords" content="博客,梁栋"/><meta name="author" content="梁栋"/><meta name="description" content="个人网站"/><meta http-equiv="Content-Type" content="text/html;charset=gbk"/><title>个人网站</title><style>body {margin : 0;padding 0;}.top_div {margin : 0;width :100%;height : 180px;background-color : yellow;}.top_main_div {width : 960px;height : 180px;background-color : blue;margin-left : 95px;float : left;}.top_log_div {width : 150px;height : 50px;background-color : white;float: right;text-indent : 20px;line-height : 50px;font-size : 20px;}.login {background : pink;padding : 0;margin-right : 20px;}.register {background : pink;padding : 0;}.menu_bar{background : green;width : 100%;height : 50px;}.menu {height : 50px;width : 700px;background : red;margin-left:95px;float : left;}.search_div {height : 50px;width : 100px;background : pink;float : left;}</style></head><body><div class="top_div"> <div class="top_main_div"> <div class="top_log_div"> <a class="login">登陆</a> <a class="register">注册</a> </div> </div></div><div class="menu_bar"> <div class="menu"></div> <div class="search_div"></div></div></body></html>
It’s centered in IE, but it’s to the left in Chrome and Firefox. How can the layout solve browser compatibility? Can I ask for a permanent standard? Relieve such problems. .
Reply to discussion (solution)
What I see under FF and ie8 are left-leaning
You are defining The style of top_main_div is not defined according to the centered display, but is displayed according to the resolution of 1024*768. There must be errors
<center class="top_div"> <div class="top_main_div"> <div class="top_log_div"> <a class="login">登陆</a> <a class="register">注册</a> </div> </div></center>
Change the outermost div into center, then modify the corresponding style sheet, remove float and margin-left, and then it can be displayed in the center. However, it seems that
is not supported in XHTML 1.0 Strict DTD. . . http://www.cnblogs.com/zhutianxiang/archive/2012/01/19/2320349.html
There is an answer in this link, you need to set display: inline.
display : inline
.top_main_div {width : 960px;height : 180px;background-color : blue;margin-left : 95px;margin:0 auto;}
To center, marginleft and marginright must be set to auto at the same time, and cannot be floating
<!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"><head><meta name="keywords" content="博客,梁栋"/><meta name="author" content="梁栋"/><meta name="description" content="个人网站"/><meta http-equiv="Content-Type" content="text/html;charset=gbk"/><title>个人网站</title><style>* { margin: 0px auto; padding: 0px;}.top_div { width : 960px; height : 180px; background-color : yellow;}.top_main_div { width : 960px; height : 180px; background-color : blue; float : left;}.top_log_div { width : 150px; height : 50px; background-color : white; float: right; text-indent : 20px; line-height : 50px; font-size : 20px;}.login { background : pink; margin-right : 20px;}.register { background : pink;}.menu_bar{ background : green; width : 960px; height : 50px;}.menu { height : 50px; width : 700px; background : red; float : left;}.search_div { height : 50px; width : 100px; background : pink; float : left;}</style></head><body><div class="top_div"> <div class="top_main_div"> <div class="top_log_div"> <a class="login">登陆</a> <a class="register">注册</a> </div> </div></div><div class="menu_bar"> <div class="menu"></div> <div class="search_div"></div></div></body></html>
When writing css, add
....
More practice Naturally you will understand. It should be like centered body{margin:0px auto;} and outer layer .top_main_div{margin:0px auto;}. This is not a bug compatibility issue, but a problem with the way you write the style itself.
The peripheral layer mentioned above is wrong. A new outermost layer is added to include all internal layers.
I learned it and have solved it. Thank you everyone.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

To build a website with powerful functions and good user experience, HTML alone is not enough. The following technology is also required: JavaScript gives web page dynamic and interactiveness, and real-time changes are achieved by operating DOM. CSS is responsible for the style and layout of the web page to improve aesthetics and user experience. Modern frameworks and libraries such as React, Vue.js and Angular improve development efficiency and code organization structure.

The article discusses the differences between HTML tags , , , and , focusing on their semantic vs. presentational uses and their impact on SEO and accessibility.

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.
