分区大小自动调整内容大小 [英] Div Size Automatically size of content

查看:78
本文介绍了分区大小自动调整内容大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为侧边栏小部件创建h2标头,但我希望div类的宽度为内容变为的任何宽度.看来我不能只是设置宽度,因为那些标题内容长而内容短的标题就弄糟了.

I am trying to make a h2 header for sidebar widgets but I want the width of the div class to be whatever width the content becomes. It seems I can't just set a width because those headlines with longer content then shorter content makes it break.

如何根据内容的长度简单地拉伸/更改宽度?任何帮助将不胜感激.

How can I simply make width stretch/change depending on the length of content there is? Any help would be greatly appreciated.

推荐答案

据我所知,display: inline-block是您可能需要的.那将使它看起来像是内联的,但仍然允许您使用诸如margin之类的东西.

As far as I know, display: inline-block is what you probably need. That will make it seem like it's sort of inline but still allow you to use things like margins and such.

这篇关于分区大小自动调整内容大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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