我试图通过将flex-grow属性设置为1来使flex-box容器中的项目均匀分布,但它没有任何影响。在包裹之前,物品的列根据最宽的尺寸确定。在所有项目中均匀分配空间的正确方法是什么?
# Without touching the `id` column, I create a sequential column `my_id`, assuming that the name of the table is `times`:
alter table times add my_id int(3) not null after id;
SET @count = 0;
UPDATE times SET my_id = @count:= @count + 1;
# I use a temporary table `times2` that starts with the second row of the `times_from` column; Here, 9999 can be any large enough number:
create temporary table times2 as select my_id, time_from from times limit 1, 9999;
# Now I add a new column `time_end` to the original table. I update it with data from `time_from` column but 'shifted' by one row upwards:
alter table times add time_end int(2) not null;
update times a join times2 b on a.my_id = (b.my_id - 1) set a.time_end = b.time_from;
# Ensure that the value of `time_end` in the last row is not zero:
update times set time_end = time_to order by my_id desc limit 1;
# The required value is taken by using the minimum of columns `time_from` and `time_end`:
select sum(LEAST(time_to,time_end) - time_from) from times;
# Uncomment below to clean up just after getting the results:
# alter table times drop column my_id;
# alter table times drop column time_end;
如何让所有带有flex-item类的容器均匀分布,所以列的宽度都相同?
答案 0 :(得分:0)
如果你想拥有相同的宽度,那么你需要定义每个元素flex-grow:1
。或者在元素之间只需要空格,那么只有justify-content: space-between;
到父div就足够了。你不需要定义flex-grow:1,如果不需要相等的宽度
.flex-item{
display: flex;
justify-content: space-between;
}
.flex-item input, .flex-item label, .flex-item span {flex-grow:1}
<div class="flex-box">
<div class="flex-item" ng-repeat="campaign in mvm.regionCampaigns.results | orderBy:'name' track by campaign.id">
<input type="checkbox">
<label>test</label>
<span>test</span>
</div>
</div>
希望这对你有所帮助。