【发布时间】:2015-08-14 22:59:49
【问题描述】:
我目前创建了一个并排的两列 div,每个 div 占 50%。我正在试图弄清楚如何使左 div 70% 和右 div 30%。
此外,除了 2 列 div。如果我想创建一个 4 col div,每个 25% 和一个 5 column div,每个 20%。我该怎么做?
.container-2col {
clear: left;
float: left;
width: 100%;
overflow: hidden;
background: none;
}
.container-1col {
float: left;
width: 100%;
position: relative;
right: 50%;
background: none;
}
.col1 {
float: left;
width: 46%;
position: relative;
left: 52%;
overflow: hidden;
}
.col2 {
float: left;
width: 46%;
position: relative;
left: 56%;
overflow: hidden;
}
<div class="container-2col">
<div class="container-1col">
<div class="col1">
<p>Delicious and crunchy, apple fruit is one of the most popular and favorite fruits among the health conscious, fitness lovers who firmly believe in the concept of “health is wealth.” This wonderful fruit is packed with rich phyto-nutrients
that, in the true sense, indispensable for optimal health. Certain antioxidants in apple have several health promoting and disease prevention properties, and thereby, truly justifying the adage, “an apple a day keeps the doctor away.”</p>
</div>
<div class="col2">
<p>Vegetables, like fruits, are low in calories and fats but contain good amounts of vitamins and minerals. All the Green-Yellow-Orange vegetables are rich sources of calcium, magnesium, potassium, iron, beta-carotene, vitamin B-complex, vitamin-C,
vitamin-A, and vitamin K.</p>
</div>
</div>
</div>
这是我的 jsfiddle:http://jsfiddle.net/huskydawgs/zhckr47h/3/
【问题讨论】:
-
不确定我是否遵循,但是将
.col宽度更改为 64% 并将.col2宽度更改为 28% 怎么样?喜欢this?由于您的左右当前各占 46%,因此 64% 和 28% 的总数相同 (92%),但余额为 70:30 而不是 50:50。 -
"如果我想创建一个 4 col div,每个 25% 和一个 5 column div,每个 20%。我该怎么做?" - 这是不可能的,它是宽度的 120%:)
-
70% 和 30% 在 100% 标签内
标签: html css multiple-columns