问答详情
源自:13-6 万事无绝对 -层模型之绝对定位

代码写完,没有得到想要的效果

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>absolute样式</title>

<style type="text/css">

div{

    width:200px;

    height:200px;

border:2px red solid;

float:right;

position:absolute;

    right:200px

top:20px;

    }

</style>

</head>

<body>

<div id="div1"></div>

</body>

</html>


提问者:慕哥0448528 2019-01-21 16:50

个回答

  • 慕虎9317830
    2019-01-21 17:31:51
    已采纳

    border:2px red solid;  应该是:border:2px solid red ; 规范

    right:200px   top:20px;  中间少了分号所以没生效


  • 慕雪9269387
    2019-01-21 17:46:36

    <!DOCTYPE HTML>

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title>absolute样式</title>

    <style type="text/css">

    div{

        width:200px;

        height:200px;

       border:2px red solid;

       float:right;

       position:absolute;

       right:200px;

      top:20px;

        }

    </style>

    </head>

    <body>

    <div id="div1"></div>

    </body>

    </html>