如何填充所有空间的div 100%与3 divs相同的大小? [英] How can I fill all space of a div 100% with 3 divs with the same size?

查看:86
本文介绍了如何填充所有空间的div 100%与3 divs相同的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个内部有100%宽度和3 div div.wrap
我需要3 div 具有相同的宽度,并且可以填充 div.wrap 的所有空间。

I have a div.wrap with 100% width and 3 div inside it. I need the 3 div have the same width and could fill all the space of div.wrap.

我试过这样做:
html:

I've tried to do something like that: html:

<div class="wrap">
    <div></div>
    <div></div>
    <div></div>
</div>

css:

.wrap{width:100%;position:relative;}
.wrap div{width:33.3%;float:left;}

但是在绝对右边,我有一些像2px的空白,我需要填充所有的空间。有没有人知道这个解决方案?

But on the absolute right side, i have something like 2px blank, I need to fill all space. Does anyone know a solution for this?

推荐答案

因为你只能设置一个元素的宽度, c $ c> 1px ,可能有一个div比其他的大,你不能真正避免这一点。话虽如此,要使最后一个div填充剩余的 1-2px ,请执行以下操作:

Since you can only set the width of an element with a maximum precision of 1px, there may be one div that is larger than the others and you can't really avoid this. Having said that, to make the last div fill the remaining 1-2px, do this:

.wrap #div3 {width:33.4%;}

$ c>#div3 是最后一个 div (或任何div,但只有一个)的ID。

where #div3 is the id of the last div (or any of the divs, but only one).

这篇关于如何填充所有空间的div 100%与3 divs相同的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆