HTML+CSS+JavaScript入门代码

今天看了一本JavaScript入门的书,书上的案例特别简单,可以当做html,css,javascript入门的案例

<html>
<head>
<title>My Dream Car</title>
</head>
<body>
<div id="car">
这辆 <span id="modelyear"></span> 年生产的公共汽车只要¥<span id="pricetag"></span>元
<div id="body"></div>
<div id="frontwheel"></div>
<div id="backwheel"></div>
</div>
<style type="text/css">
#car {
      font-family:Arial;
      }
#body {
      position:absolute;
      top:50px;
      width:80%;
      height:100px;
      background-color:#000000;
      text-align:center;
      }
#backwheel {
      position:absolute;
      left:10%;
      top:130px;
      background-color:#ffffff;
      border:3px solid black;
      border-radius:50%;
      width:40px;
      height:40px;
     }
#frontwheel {
        position:absolute;
      left:55%;
      top:130px;
      background-color:#ffffff;
      border:3px solid black;
      border-radius:50%;
      width:40px;
      height:40px;
    }
</style>
<script>
var dreamCar = {
  make:"广汽集团",
  model:"2018款",
  color:"green",
  year:2018,
  bodyStyle:"公共汽车",
  price:450000
  };
  document.getElementById("pricetag").innerHTML = dreamCar.price;
  document.getElementById("modelyear").innerHTML = dreamCar.year;
  document.getElementById("body").style.backgroundColor = dreamCar.color;
  document.getElementById("body").innerHTML = dreamCar.make+"  "+dreamCar.model;
 
</script>
</body>
</html>

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值