How to merge two divs

前端 未结 3 942
别跟我提以往
别跟我提以往 2020-12-11 07:45

I have two divs which should looks like one figure. The problem is with the border of the circular block. See pic. below. css were added below

相关标签:
3条回答
  • 2020-12-11 07:45

    This is not possible with CSS.

    Solution A) involves graphics used as background and solution B) uses a layer behind the vertical bar to draw the oval, a second layer for the bar itself and a third DIV for the X and it's link.

    0 讨论(0)
  • 2020-12-11 07:51

    Use z-index property.

    #nameWidgeteMain, #nameWidgeteMain2 {
      width: 279px;
      height: 400px;
      top: 0px;
      position: absolute;
      background-color: rgb(237,237,237);
      box-shadow: 0 0 20px rgba(0,0,0,0.08)
    }
    
    #nameWidgeteMain2 {
      z-index: -2;
      border: 1px solid #dbe0e3;
    }
    
    .nameWidgeteCloseArea {
      z-index: -1;
      ...
    }
    

    This is not merging but the result is the same.

    0 讨论(0)
  • 2020-12-11 08:09

    Maybe try something like this: http://jsfiddle.net/VNAZA/

    Uses two divs: one with just the border, which gets layered under the rectangle and another with the actual content, layering over the rectangle. This way you can also apply css box-shadow to the lower div.

    .container{
            position:relative;
            width: 50px;
            height: 150px;
        }
        
        .rect{
            position:absolute;
            width: 50px;
            height: 150px;
            background: #eee;
            border: 1px solid #000;
            z-index: 5;
            -webkit-box-shadow: 2px 2px 10px 2px #cccccc;
            box-shadow: 2px 2px 10px 2px #cccccc;
        }
        
        .round_content{
            position: absolute;
            top: 50px;
            right: -25px;
            width: 50px;
            line-height: 50px;
            background: #eee;
            z-index: 6;
            text-align:center;
            -webkit-border-radius: 10px;
            -moz-border-radius: 10px;
            border-radius: 10px;
        }
        
        .round_border{
            position: absolute;
            top: 49px;
            right: -26px;
            width: 52px;
            height: 50px;
            line-height: 52px;
            border: 1px solid #000;
            z-index: 4;
            text-align: center;
            -webkit-border-radius: 10px;
            -moz-border-radius: 10px;
            border-radius: 10px;
            -webkit-box-shadow: 2px 2px 10px 2px #cccccc;
            box-shadow: 2px 2px 10px 2px #cccccc;
        }
        <div class="container"> 
          <div class="rect"></div>
          <div class="round_content">x</div>
          <div class="round_border"></div>
        </div>

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