HTML怎样设置页面两列宽度,html – 如何调整两列div的百分比宽度?

本文探讨如何在HTML和CSS中实现不同列宽需求,如两列div分别占70%和30%,以及创建等比例的五列div。通过实例演示了如何使用浮动和定位属性来调整div布局,同时提供了相应的代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我目前创建了一个并排的两列div,每个div为50%.我试图找出如何使左div 70%和右div 30%.

此外,除了2列div.如果我想创建一个25%的每个25%的div和每个20%的五列div.我该怎么做?

这是我的HTML:

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.”

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.

Here's my CSS:

.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;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值