Home > Web Front-end > HTML Tutorial > Can anyone help enlighten me on the browser compatibility issue? I'm so annoyed. _html/css_WEB-ITnose

Can anyone help enlighten me on the browser compatibility issue? I'm so annoyed. _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:09:44
Original
950 people have browsed it



<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>
Copy after login


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>
Copy after login


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;}
Copy after login

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>
Copy after login

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.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template