weixin_49317383
2021-01-30 16:12
采纳率: 80%
浏览 45

css定位的问题,如何让图中蓝色元素保持在可视区域的最右侧

<head>
  <style>
    #app {
      position: relative;
      width: 400px;
      height: 400px;
      background-color: pink;
      overflow-x: scroll;
    }
    .dd {
      position: absolute;
      width: 1000px;
      height: 400px;
    }
    .asd {
      position: absolute;
      right: 0;
      left: auto;
      width: 50px;
      height: 400px;
      background-color: powderblue;
    }
  </style>
</head>
<body>
  <div id="app">
    <div class="dd"></div>
    <div class="asd"> </div>
  </div>
</body>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • 天际的海浪 2021-01-30 22:36
    已采纳
    <head>
      <style>
        #app {
          position: relative;
          width: 400px;
          height: 400px;
          background-color: pink;
        }
        .aa {
          position: absolute;
          width: 100%;
          height: 100%;
          overflow-x: scroll;
        }
        .dd {
          position: absolute;
          width: 1000px;
          height: 400px;
        }
        .asd {
          position: absolute;
          top: 0;
          right: 0;
          width: 50px;
          height: 400px;
          background-color: powderblue;
        }
      </style>
    </head>
    <body>
      <div id="app">
        <div class="aa">
    	    <div class="dd"></div>
        </div>
        <div class="asd"> </div>
      </div>
    </body>
    
    点赞 打赏 评论
  • Menkongkong 2021-02-01 16:27

    position:fixed;

    right:0;

    点赞 打赏 评论

相关推荐 更多相似问题