css position usage and cause page deformation JS processing method

Source: Internet
Author: User
Keywords Webpage making CSS tutorial
Tags based block browser content css tutorial default document it is

Absolute and relative positioning in position

Positioning: position: absolute; Syntax: <div style = "position: absolute; left: 100px; top: 100px"> </ div>
The following two situations
1, there is no set top, right, bottom, left the default, based on the parent's "original content area" as the original point
2, there is set top, right, bottom, left the situation, here is divided into two cases are as follows:
(1), the parent does not have the position attribute, and the upper left corner of the browser (ie body) locates the "original coordinate of the coordinate", and the position is determined by the top, right, bottom, left attributes
(2), the parent has a position property, the parent's "original coordinate point" as the original point

Relative position
With reference to the "original point of the content area" of the parent as the original point, the parent does not have the "original point of the content area" of the body as the original point, and the position is determined by the top, right, bottom, left attributes and is occupied outside the parent block The same size, so it is not recommended.

Regardless of the relative positioning or absolute positioning a bit to note is
left and right can only set one
Top and bottom can only set one

If the page is distorted because of the position you can use the following js code to solve

var ietest = function ()
{
if ($ .browser.msie) {
if ($ .browser.version == "6.0")
{
var _width = document.documentelement.clientwidth + 29; / / desktop resolution size
$ ("# nav"). css tutorial ("left", ((_ width-950) / 2) -15); // reset the value
return false;
}
return false;
}
return false;
}
window.onresize = ietest; // Trigger events when scaling the form
The position property, we can choose 4 different types of positioning, which will affect the way the element box is generated.

The meaning of the value of the position attribute:

static
The element box is generated normally. A block-level element generates a rectangle that, as part of the document stream, creates one or more line boxes in its parent element.
relative
The element box is offset by a distance. The element still retains its shape before it is positioned, and the space it originally occupied remains.
absolute
The element box is completely removed from the document flow and positioned relative to its containing block. The containing block may be another element in the document or the initial containing block. Elements of the original document flow in the normal space will be closed, as if the original element does not exist the same. The element is positioned to produce a block-level box, regardless of what type of box it originally generated in the normal stream.
fixed
The behavior of the element box is similar to setting position to absolute, but the containing block is the window itself.
Tip: Relative positioning is actually considered part of the normal flow positioning model because the position of the element is relative to its position in the normal flow.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.