黑马前端——days14_js

案例 1

页面框架文件

<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="style1.css">
</head>

<body>
  <script src="index1.js"></script>
</body>

</html>

案例1

格式文件

span {
  /* 需要給span指定内外边距 */
  display: inline-block;
  width: 80px;
  height: 30px;

  text-align: center;
  line-height: 30px;
  
  padding: 5px 10px;
  margin: 2px;
  
  border: 1px solid #000;
  border-radius: 5px;
  
  box-shadow: 2px 2px 2px rgba(255, 192, 203, 0.4);
  color: hotpink;
  background-color: rgba(255, 192, 203, 0.1);
}

事件文件

for (let i = 1; i <= 9; i++) {
  for (let j = 1; j <= i; j++) {
    document.write(`<span>${j} * ${i} = ${i * j}</span>`)
  }
  document.write(`<br>`)
}

案例 2

页面框架文件

<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="style2.css">
</head>

<body>
  <script src="index2.js"></script>
</body>

</html>

案例2

格式文件

* {
  margin: 0;
  padding: 0;
}

.box {
  /* 弹性盒子布局 */
  display: flex;
  width: 700px;
  height: 300px;

  border-left: 1px solid #000;
  border-bottom: 1px solid #000;

  margin: 50px auto;
  text-align: center;
  /* 均匀排列每个元素 每个元素周围分配相同的空间 */
  justify-content: space-around;
  /* 将元素与 flex 容器的主轴末端或交叉轴末端对齐 */
  align-items: flex-end;
}

.box>div {
  /* 弹性盒子布局 */
  display: flex;
  width: 50px;
  background-color: greenyellow;
  /* 定义主轴和方向 */
  flex-direction: column;
  /* 均匀排列每个元素 首个元素放置于起点 末尾元素放置于终点 */
  justify-content: space-between;
}

.box div span {
  /* 默认文字在边框顶端 将文字移出去 */
  margin-top: -20px;
}

.box div h4 {
  width: 70px;
  /* 默认文字在边框底部 将文字移出去并居中 */
  margin-bottom: -35px;
  margin-left: -10px;
}

事件文件

let arr = []
for (let i = 1; i <= 4; i++) {
  arr.push(prompt(`请输入第${i}季度的数据`))
}
document.write(`<div class="box">`)
for (let i = 0; i < 4; i++) {
  document.write(`
        <div style="height: ${arr[i]}px;">
          <span>${arr[i]}</span>
          <h4>第${i + 1}季度</h4>
        </div>
  `)
}
document.write(`</div>`)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

胆怯与勇敢

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值