web之css8

17 篇文章 0 订阅
16 篇文章 0 订阅

Homework8

html

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>

<body>
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
</body>

</html>

要求

  1. body的高度设为2000px,外边距设为0。
  2. 所有div标签的样式设置为:
  1. 宽度与高度均为200px;
  2. 背景颜色设置为lightblue;
  3. 外边距设置为20px;
  1. 第一个div的position属性为static。
  2. 第二个div的样式设置为:
  1. position的值为relative;
  2. left的值为50px;
  3. top的值为15px;
  1. 第三个div的样式设置为:
  1. position的值为absolute;
  2. 背景颜色为rgba(0, 0, 255, 0.5);
  3. left的值为30px;
  1. top的值为30px;
  1. 第四个div的样式设置为:
  1. position的值为fixed;
  2. 背景颜色为rgba(0, 255, 0, 0.5);
  3. left的值为100px;
  4. top的值为250px;
  1. 第十个div的样式为:
  1. position的值为sticky;
  2. 背景颜色为rgba(255, 0, 0, 0.5);
  3. bottom的值为10px;

css实现:

style>
    body {
      height: 2000px;
      margin: 0;
    }

    div {
      width: 200px;
      height: 200px;
      background-color: lightblue;
      margin: 20px;
    }

    div:nth-of-type(2) {
      position: relative;
      left: 50px;
      top: 15px;
    }

    div:nth-of-type(3) {
      position: absolute;
      left: 30px;
      top: 30px;
      background-color: rgba(0, 0, 255, 0.5);
    }

    div:nth-of-type(4) {
      position: fixed;
      left: 100px;
      top: 250px;
      background-color: rgba(0, 255, 0, 0.5);
    }

    div:nth-of-type(10) {
      position: sticky;
      bottom: 10px;
      background-color: rgba(255, 0, 0, 0.5);
    }
  </style>

html+css:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body {
      height: 2000px;
      margin: 0;
    }

    div {
      width: 200px;
      height: 200px;
      background-color: lightblue;
      margin: 20px;
    }

    div:nth-of-type(2) {
      position: relative;
      left: 50px;
      top: 15px;
    }

    div:nth-of-type(3) {
      position: absolute;
      left: 30px;
      top: 30px;
      background-color: rgba(0, 0, 255, 0.5);
    }

    div:nth-of-type(4) {
      position: fixed;
      left: 100px;
      top: 250px;
      background-color: rgba(0, 255, 0, 0.5);
    }

    div:nth-of-type(10) {
      position: sticky;
      bottom: 10px;
      background-color: rgba(255, 0, 0, 0.5);
    }
  </style>
</head>

<body>
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
  <div>7</div>
  <div>8</div>
  <div>9</div>
  <div>10</div>
</body>

</html>

实现界面:

 

 

 

 

 

加油 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

AAA阿魏

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

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

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

打赏作者

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

抵扣说明:

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

余额充值