position



значения свойства:


  • static
  • absolute
  • fixed
  • relative
  • inherit



css/style.css
  • * {
  •  margin: 0;
  •  padding: 0;
  • }
  •  
  • .a {
  •  height: 400px;
  •  width: 400px;
  •  position: absolute;
  •  top: 50%;
  •  left: 50%;
  •  margin-top: -200px;
  •  margin-left: -200px;
  •  border: 1px solid #808080;
  • }
  •  
  • #div1, .b, .c {
  •  width: 100px;
  •  height: 100px;
  •  background-color: #7092BE;
  • }
  •  
  • #div1 {
  •  top: 150px;
  •  left: 150px;
  • }
  •  
  • .c {
  •  bottom: 25px;
  •  left: 25px;
  •  position: fixed;
  • }
* {
 margin: 0;
 padding: 0;
}

.a {
 height: 400px;
 width: 400px;
 position: absolute;
 top: 50%;
 left: 50%;
 margin-top: -200px;
 margin-left: -200px;
 border: 1px solid #808080;
}

#div1, .b, .c {
 width: 100px;
 height: 100px;
 background-color: #7092BE;
}

#div1 {
 top: 150px;
 left: 150px;
}

.c {
 bottom: 25px;
 left: 25px;
 position: fixed;
}


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  •  <div class="a">
  •   <div id="div1"></div>
  •  </div>
  •  <div class="b"></div>
  •  <div class="c"></div>
  • <script>
  •  /*JavaScript*/
  •  document.getElementById("div1").style.position = "relative";
  •  /*jQuery*/
  •  $(document).ready(function () {
  •   $(".b").css({ "position": "static" });
  •  });
  • </script>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <link href="css/style.css" rel="stylesheet" />
  •  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  • </head>
  • <body>
  •  <div class="a">
  •   <div id="div1"></div>
  •  </div>
  •  <div class="b"></div>
  •  <div class="c"></div>
  • <script>
  •  /*JavaScript*/
  •  document.getElementById("div1").style.position = "relative";
  •  /*jQuery*/
  •  $(document).ready(function () {
  •   $(".b").css({ "position": "static" });
  •  });
  • </script>
  • </body>
  • </html>