How can I hide an element off the edge of the screen?

前端 未结 7 498
醉话见心
醉话见心 2020-12-05 06:56

I\'ve got a div that I want to position partially off-screen like so:

div{
    position: absolute;
    height: 100px;
    width: 100px;
    right: -50px;
            


        
7条回答
  •  心在旅途
    2020-12-05 07:36

    Yes, just create an enclosing div with overflow: hidden, like this:

    .outer {
      overflow: hidden;
      position: relative;
    }
    .inner {
      position: absolute;
      height: 100px;
      width: 100px;
      right: -50px;
      top: 50px;
    }
    CONTENT

    Example: http://jsfiddle.net/Uj3eQ/

提交回复
热议问题