CSS自动宽度Child'div在父'div' [英] CSS Auto Width Child 'div's in Parent 'div'
问题描述
我有一个称为面板的父div中的item的多个子div。
最简单的方法是使itemdiv具有相等的宽度,对面,占据了面板div的整体?
现在我们已经设置了一个已知数量的元素的静态宽度。
I have multiple child divs for "item" in a parent div called "panel."
What is the easiest way to have the "item" divs to have equal widths and, side-by-side, take up the entirety of the "panel" div?
I have them set up now with a static width for a known number of elements. But want to be able to add elements and have it auto-size.
推荐答案
没有神奇的方式这样做。你可以做什么可能虽然,是使用服务器端计算有多少项目div,并基于这些给它们的宽度。
There is no magical way of doing this. What you can do probably though, is use server-side to calculate how many item divs there are, and based on that give them widths.
你也可以客户端使用JS编写脚本以使它们都相等。
You can also client-side script this with JS to make them all equal.
这篇关于CSS自动宽度Child'div在父'div'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!