HTML CSS Reference/CSS Attributes and Javascript Style Properties/position

Материал из Web эксперт
Перейти к: навигация, поиск

"position" Example

    
<head>
<script language="JavaScript">
    function function1(){
        myDiv.style.position = "absolute"; 
    }
</script>
</head>
<body>
<br>
<br>
<br>
<br>
<br>
<div id="myDiv" 
     style="background-color:#ccffcc; 
            width:300; 
            cursor:hand" 
     onclick="function1()">
     Click Here to set the position to absolute
</div>
</body>



"position" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<a>                             <address>                     |
|                |<applet>                        <b>                           |
|                |<bdo>                           <big>                         |
|                |<blockquote>                    <button>                      |
|                |<center>                        <cite>                        |
|                |<code>                          currentStyle                  |
|                |<custom>                        <dd>                          |
|                |defaults                        <dfn>                         |
|                |<dir>                           <div>                         |
|                |<dl>                            <dt>                          |
|                |<em>                            <embed>                       |
|                |<fieldset>                      <font>                        |
|                |<form>                          <hn>                          |
|                |<hr>                            <i>                           |
|                |<iframe>                        <img>                         |
|                |<input type="button">           <input type="checkbox">       |
|                |<input type="file">             <inputtype="image">           |
|                |<input type="password">         <input type="radio">          |
|                |<input type="reset">            <input type="submit">         |
|                |<input type="text">             <isindex>                     |
|                |<kbd>                           <label>                       |
|                |<legend>                        <li>                          |
|                |<listing>                       <marquee>                     |
|                |<menu>                          <object>                      |
|                |<ol>                            <p>                           |
|                |<pre>                           <ruby>                        |
|                |runtimeStyle                    <s>                           |
|                |<samp>                          <select>                      |
|                |<small>                         <span>                        |
|                |<strike>                        <strong>                      |
|                |style                           <sub>                         |
|                |<sup>                           <table>                       |
|                |<td>                            <textarea>                    |
|                |<th>                            <tr>                          |
|                |<tt>                            <u>                           |
|                |<ul>                            <var>                         |
|                |<xmp>                                                         |
+----------------+--------------------------------------------------------------+



"position" Possible Values

Possible Values
static            The default; position is determined by the normal 
                  flow of HTML elements
                  
absolute          Position is relative to the parent element
relative          Position is calculated according to the normal 
                  flow of the HTML elements



"position" Syntax and Note

Note:
Defines the positioning type.
Syntax:
    
element { position: value }
elementID.style.position = "value"
document.all.elementID.style.position = "value" // IE only