表宽度超过容器的宽度 [英] Table width exceeds container's width

查看:86
本文介绍了表宽度超过容器的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个报表应用程序,它生成的HTML表格可以是多行高和多列长(有时40个或更多)。

I'm working on a reporting application which generates HTML tables that can be many rows high and many columns long (sometimes 40 or more).

问题是,这些表中有许多扩展到它们包含的div之外,它只是看起来很丑陋。由于某些原因,包含的div不会伸展到表的大小。

The problem is, many of these tables stretch outside of their containing div, and it just looks ugly. For some reason, the containing div won't stretch to the size of the table.

所以,这里是我的问题:是否可以使一个包含元素拉伸到使用CSS的表格宽度?

So, here's my question: Is it possible to make a containing element stretch to the width of the table using CSS?

这里有一个 jfiddle <

Here's a jfiddle with the problem at it's most basic level.

提前感谢

推荐答案

给你的容器一个float来强制它伸展到内容的宽度:

Give your container a float to force it to stretch to the width of the content:

div{
    border:2px solid #F00;
    padding:10px;   
    float: left; 
}

小提琴

这篇关于表宽度超过容器的宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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