width



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


  • auto
  • px
  • %
  • inherit



css/style.css
  • .a {
  •  width: 300px;
  •  height: 150px;
  •  background-color: #3BA9DE;
  • }
  •  
  • #div1 {
  •  height: 150px;
  •  background-color: #56A31D;
  • }
  •  
  • .b {
  •  height: 150px;
  •  background-color: #852E76;
  • }
.a {
 width: 300px;
 height: 150px;
 background-color: #3BA9DE;
}

#div1 {
 height: 150px;
 background-color: #56A31D;
}

.b {
 height: 150px;
 background-color: #852E76;
}


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>
  •  <br />
  •  <br />
  •  <div id="div1"></div>
  •  <br />
  •  <br />
  •  <div class="b"></div>
  • <script>
  •  /*JavaScript*/
  •  document.getElementById("div1").style.width = "300px";
  •  /*jQuery*/
  •  $(document).ready(function () {
  •   $(".b").css("width", "300px");
  •  });
  • </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>
  •  <br />
  •  <br />
  •  <div id="div1"></div>
  •  <br />
  •  <br />
  •  <div class="b"></div>
  • <script>
  •  /*JavaScript*/
  •  document.getElementById("div1").style.width = "300px";
  •  /*jQuery*/
  •  $(document).ready(function () {
  •   $(".b").css("width", "300px");
  •  });
  • </script>
  • </body>
  • </html>