<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test</title>
<style>
.ribbon-left {left: 10px;top: 20px; width: 400px; height: 300px;position: absolute;}
.css-table {display: table;margin: 0;padding: 0;background-color: red;}
.css-row { display: table-row; }
.css-cell {display: table-cell;vertical-align: middle; }
.ribbon-left-middle {width: 80%;bottom: 0;padding-left: 5px;position: relative; }
.ribbon-left-middle-inner {top: 5px;position: absolute;}
</style>
</head>
<body>
<div class="ribbon-left">
<div class="css-table">
<div class="css-row">
<div class="css-cell ribbon-left-middle">
<div class="ribbon-left-middle-inner">
<div class="productElements">Product elements</div>
<div class="productDescription">Product description</div>
<div class="productUsage">Product usage</div>
</div>
</div>
</div>
</div>
</div>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test</title>
<style>
.ribbon-left {left: 10px;top: 20px; width: 400px; height: 300px;position: absolute;}
.css-table {display: table;margin: 0;padding: 0;background-color: red;}
.css-row { display: table-row; }
.css-cell {display: table-cell;vertical-align: middle; }
.ribbon-left-middle {width: 80%;bottom: 0;padding-left: 5px;position: relative; }
.ribbon-left-middle-inner {top: 5px;position: absolute;}
</style>
</head>
<body>
<div class="ribbon-left">
<div class="css-table">
<div class="css-row">
<div class="css-cell ribbon-left-middle">
<div class="ribbon-left-middle-inner">
<div class="productElements">Product elements</div>
<div class="productDescription">Product description</div>
<div class="productUsage">Product usage</div>
</div>
</div>
</div>
</div>
</div>
這是我的榜樣。我已經定義了紅色背景顏色到CSS表格父div。爲什麼文本在子div中沒有紅色背景?背景是不是傳播給孩子?
只有我有多個「css-cell」div的相同示例,紅色背景在那裏。 我應該在這裏改變什麼?
您可以設置子元素,以「繼承」 – IeuanG
的背景顏色,你可以接受的答案嗎? –