Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

css - How to merge two divs

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

input and output needed

#nameWidgeteMain {
  width: 279px;
  height: 400px;
  top: 0px;
  position: absolute;
  background-color: rgb(237,237,237);
  border: 1px solid #dbe0e3;
  box-shadow: 0 0 20px rgba(0,0,0,0.08)
}
.nameWidgeteCloseArea {
  position: absolute;
  width: 22px;
  height: 31px;
  top: 7px;
  left: 270px;
  background-color: rgb(237,237,237);
  color: white;
  border: 1px solid #dbe0e3;
  border-top-left-radius: 50%;
  border-top-right-radius: 50%;
  border-bottom-right-radius: 50%;
  border-bottom-left-radius: 50%;
  text-align: center;
}

#nameWidgeteCloseTitle {
  padding-top: 5px;
  left: auto;
  font-family: sans-serif;
  font-size: 12pt;
  color: rgb(158, 158, 158);
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...