如何让子div元素具有与父元素相同的背景纹理?背景是小方块的纹理,但是当我尝试给子元素提供与父元素相同的背景时,方块不会排列。有什么想法吗?
HTML:
<!DOCTYPE html>
<html>
<head>
<style>
.parent{
width:500px;
height:500px;
background-image:url('wallpaper324845.jpg')
}
.child{
width:200px;
height:200px;
/*how to get the same background-image*/
}
</style>
</head>
<body>
<div class="parent">
<div class="child">
</div>
</div>
</body>
</html>
答案 0 :(得分:2)
不要给孩子分配背景。
答案 1 :(得分:2)
会background-image: inherit;
这样做吗?
或background: transparent;
?