不喝百事~ 2020-12-19 21:39 采纳率: 50%
浏览 34
已采纳

web代码(HTML、css)

在单个HTML页面上,在主体中包含以下两个div container元素。使用外部样式表,向div元素添加样式,使一个div与第二个div有一些重叠(提示:使用相对或绝对定位)。两个div的四周都应该有5px的填充,一个3px的绿色虚线边框,200px的宽度和高度,它们的文本应该居中。

<div id=”first”>

This is a DIV Container

</div>

<div id=”second”>

DIVs are a powerful way to modularize presentation

</div>

  • 写回答

2条回答 默认 最新

  • 小钱要努力 2020-12-20 19:46
    关注

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <title>Document</title>

        <link rel="stylesheet" href="./web.css">

       </head>

    <body>

        <div id="first">

            This is a DIV Container

        </div>

        <div id="second">

            DIVs are a powerful way to modularize presentation

        </div>

    </body>

    </html>

     

    在html文件同级新建文本,命名为web.css,一下是css外部样式:(若是整体居中就把注释去掉,不用就删掉)

            body,html{

                padding:0;

                margin:0;

                width:100vw;

                height:100vh;

            }

            body{

                /* display:flex;

                flex-direction: column;

                justify-content: center;

                align-items: center; */

            }

            div{

                width:200px;

                height: 200px;

                margin:5px;

                border: 3px dashed green; 

                display:flex;

                justify-content: center;

                align-items: center;

            }

            div:nth-child(2){

                position: relative;

                top:-30px;

            }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 luckysheet
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误