📄 pr_class_position.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CSS Position Property</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>CSS position Property</h1>
<hr />
<a href="css_reference.asp"><img class="navup" src="../images/up.gif" alt="CSS Reference" border="0" /> Complete CSS Reference</a>
<hr />
<h2>Definition</h2>
<p>The position property places an element in a static, relative, absolute or
fixed position.</p>
<p><b>Inherited:</b> No</p>
<hr />
<h2><b>JavaScript Syntax</b></h2>
<p>CSS properties can also be dynamically changed with a JavaScript.</p>
<p><b>Scripting Syntax:</b> <i>object</i>.style.position="absolute"</p>
<p>In our HTML DOM tutorial you can find more details about the
<a href="../htmldom/prop_style_position.asp">position property</a>.</p>
<p>In our HTML DOM tutorial you can also find a full
<a href="../htmldom/dom_obj_style.asp">Style Object Reference</a>.</p>
<hr />
<h2>Example</h2>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
<tr>
<td valign="top">h1<br />
{<br />
position:absolute;<br />
left:100px;<br />
top:150px;<br />
}
</td>
</tr>
</table>
<h2>Possible Values</h2>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
<tr>
<th align="left" valign="top">Value</th>
<th align="left" valign="top">Description</th>
</tr>
<tr>
<td valign="top">static</td>
<td valign="top">Default. An element with position: static always has the
position the normal flow of the page gives it (a static element ignores any
top, bottom, left, or right declarations)</td>
</tr>
<tr>
<td valign="top">relative</td>
<td valign="top">An element with position: relative moves an element relative to its normal position, so "left:20"
adds 20 pixels to the element's LEFT position</td>
</tr>
<tr>
<td valign="top">absolute</td>
<td valign="top">An element with position: absolute is positioned at the
specified coordinates relative to its containing block. The element's position is specified with the
"left", "top", "right", and
"bottom" properties</td>
</tr>
<tr>
<td valign="top">fixed</td>
<td valign="top">An element with position: fixed is positioned at the
specified coordinates relative to the browser window. The element's position is specified with the
"left", "top", "right", and
"bottom" properties. The element remains at that position
regardless of scrolling. Works in IE7 (strict mode)</td>
</tr>
</table>
<br />
<hr />
<h2>Try-It-Yourself Demos</h2>
<p><a target="_blank" href="tryit.asp@filename=trycss_position_relative">Position:relative</a><br />
This example demonstrates how to position an element relative to its normal position.</p>
<p><a target="_blank" href="tryit.asp@filename=trycss_position_absolute">Position:absolute</a><br />
This example demonstrates how to position an element using an absolute value.</p>
<p><a target="_blank" href="tryit.asp@filename=trycss_position_fixed">
Position:fixed</a><br />
This example demonstrates how to position an element with relative to the
browser window.</p>
<p><a target="_blank" href="tryit.asp@filename=trycss_clip">Set the shape of an element</a><br />
This example demonstrates how to set the shape of an element. The element is
clipped into this shape, and displayed.</p>
<p><a target="_blank" href="tryit.asp@filename=trycss_zindex2">Z-index</a><br />
Z-index can be used to place an element "behind" another element.</p>
<p><a target="_blank" href="tryit.asp@filename=trycss_zindex1">Z-index</a><br />
The elements in the example above have now changed their Z-index.</p>
<hr />
<a href="css_reference.asp"><img class="navup" src="../images/up.gif" alt="CSS Reference" border="0" /> Complete CSS Reference</a>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -