有一个父 div 和一个子 div。在子 div 元素中使用相对定位来放置它的内容。父 div 元素边框未包含子 div 元素。尝试溢出:父 div 元素中的隐藏和填充选项,但它不起作用。 http://jsfiddle.net/p5UMA/1/ 粘贴下面的代码
<html>
<head>
<style>
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
#parid{
color:#000000;
border: 3px solid #336c2b;
width: 960px;
margin: 0 auto;
}
#childcon{
background-color: #000000;
color:#ffffff;
border: 5px solid #003748;
position:relative;
left:100px;
top:100px;
}
</style>
</head>
<body>
<div id="parid">
<div id="childcon">
child contents
</div>
</div>
</body>
</html>