CSS: Make two floating elements overlap

前端 未结 8 1677
臣服心动
臣服心动 2021-01-03 19:28

I have two divs within a container. One floats left and one floats right. Both are about 60% as wide as the container and are designed such that they overlap in the middle (

8条回答
  •  無奈伤痛
    2021-01-03 19:52

    You can only do that with positioning.

    left
    #container { width: 400px; background-color: #eee; position: relative; } #left { width: 250px; border: 1px solid #ccc; position: absolute; left: 0; top: 0; z-index: 1; } #right { width: 250px; border: 1px solid #ccc; position: absolute; right: 0; top: 0; z-index: 2; }

提交回复
热议问题