Some pages have weebox pop-up windows that are not centered, and some pages are centered, and the centering algorithm of the pop-up window is OK. Why is this?
1. Solution
As a responsible attitude towards you, you must first be informed of your decision.
Add the following code to the top of the page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
Note that this must be
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/"> <html xmlns="http:///1999/xhtml"> <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ include file="/components/common/"%> <%@ include file="/components/common/"%> <head>
And it can't be like this
<html xmlns="http:///1999/xhtml"> <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%> <%@ include file="/components/common/"%> <%@ include file="/components/common/"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/"> <head>
2. Error analysis
The basic usage method of weebox is introduced in the jquery weebox summary. So for the reason why the weebox pop-up box is not centered, we must first see if its setCenterPosition centering algorithm is reasonable.
= function() { var wnd = $(window), doc = $(document), pTop = (), pLeft = (), minTop = pTop; pTop += (() - ()) / 2; pTop = (pTop, minTop); pLeft += (() - ()) / 2; ({top: pTop, left: pLeft}); }
I found that the algorithm is still very OK, but please note that doc = $(document).
In the previous article, I also told you the solution to the weebox not displaying centeredly. So what is the connection between the reasons?
The declaration must be the first line of the HTML document, before the tag.
The declaration is not an HTML tag; it is a directive that instructs the web browser about which HTML version the page is written using.
In HTML 4.01, the declaration references DTD because HTML 4.01 is based on SGML. DTD specifies rules for markup language so that the browser can render content correctly.
Although this passage cannot directly indicate the relationship between doctype and window centering, it can be guessed from the solution that if not specified, the window is not a standard pixel value when calculating the width and height of the document, which indirectly results in the x and y coordinates of the pop-up window not being positioned accurately.
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.