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

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

"margin" Example

    
<html>
<body>
<img id="myImg" 
     src="http://www.wbex.ru/style/logo.png" 
     height="50" 
     width="50" 
     border="1">
     
<button onclick="myImg.style.margin="25 25 25 25"">25 Px Margin</button>
<button onclick="myImg.style.margin="0 0 0 0"">0 Margin</button>
</body>
</html>



"margin" is applied to

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



"margin" Syntax and Note

Note:
Controls four different margin style properties: 
    margin-top, 
    margin-right, 
    margin-bottom, 
    margin-left.
Syntax:
    
element { margin: values }
elementID.style.margin = "values"
document.all.elementID.style.margin = "values" // IE only