How to place div in top right hand corner of page

前端 未结 4 1169
半阙折子戏
半阙折子戏 2021-01-30 16:15

How do you float a div to the top right hand corner of a page using css? I want to float the topcorner div which is below:

相关标签:
4条回答
  • 2021-01-30 16:39

    Try css:

    .topcorner{
        position:absolute;
        top:10px;
        right: 10px;
     }
    

    you can play with the top and right properties.

    If you want to float the div even when you scroll down, just change position:absolute; to position:fixed;.

    Hope it helps.

    0 讨论(0)
  • 2021-01-30 16:43
    <style type="text/css">
     .topcorner{
      position:absolute;
      top:10;
      right:15;
      }
    </style>
    

    You ca also use this in CSS external file.

    0 讨论(0)
  • 2021-01-30 16:44

    the style is:

    <style type="text/css">
     .topcorner{
       position:absolute;
       top:0;
       right:0;
      }
    </style>
    

    hope it will work. Thanks

    0 讨论(0)
  • 2021-01-30 16:44

    You can use css float

    <div style='float: left;'><a href="login.php">Log in</a></div>
    
    <div style='float: right;'><a href="home.php">Back to Home</a></div>
    

    Have a look at this CSS Positioning

    0 讨论(0)
提交回复
热议问题