我有两个带边框的div,如下图所示.
如何仅删除2个div触摸的边框,如下图所示?
这是顶部图片中使用的html和css(js小提琴:http://jsfiddle.net/paulyoder/whsC4/19/)
<html> <head> <style type="text/css"> #sideBar { float: left; width: 75px; height: 50px; border-top: 1px solid black; border-left: 1px solid black; border-bottom: 1px solid black } #balanceSheetSummary { float: left; width: 150px; height: 150px; border: 1px solid black; } body { padding: 10px; } h2 { margin: 5px; } </style> </head> <body> <div id="sideBar"> <h2>Side Bar</h2> </div> <div id="balanceSheetSummary"> <h2>Content</h2> </div> </body> </html>
解决方法
你可以这样做:
http://jsfiddle.net/sj2AD/1/
#sideBar { float: left; width: 75px; height: 50px; border-top: 1px solid black; border-left: 1px solid black; border-bottom: 1px solid black; background: red; position: relative; z-index: 2; } #balanceSheetSummary { float: left; width: 150px; height: 150px; border: 1px solid black; background: red; position: relative; z-index: 1; margin-left: -1px; } body { padding: 10px; } h2 { margin: 5px; }
我所做的是在右边添加一个负边距,使框重叠.
例如,如果左侧div高于右侧div,则确实会中断.