简体   繁体   English

如何根据在该div中输入的文本量扩展div框(菜单)?

[英]How to extend a div box(menu) based on the amount of text entered in that div?

I've been wondering how can I extend my div box square, when necessary, parallel to the amount of text I'm typing. 我一直在想,如何在必要时扩展div框的正方形,使其与我输入的文本量平行。 Let me illustrate my question with an example: 让我用一个例子说明我的问题:

http://postimg.org/image/l4mrkj0bh/ http://postimg.org/image/l4mrkj0bh/

The text is much more than the the box itself, so it overlaps. 文本比框本身多得多,因此重叠。 But If I have a shorter text, it is not a problem, because the box's size is the same, static. 但是,如果我的文字较短,那不是问题,因为框的大小是相同的,是静态的。 I want to make it dynamic. 我想让它充满活力。

Here is the CSS of the div box: 这是div框的CSS:

#centercol {
position: relative;
background:
linear-gradient(27deg, #151515 5px, transparent 5px) 0 5px,
linear-gradient(207deg, #151515 5px, transparent 5px) 10px 0px,
linear-gradient(27deg, #222 5px, transparent 5px) 0px 10px,
linear-gradient(207deg, #222 5px, transparent 5px) 10px 5px,
linear-gradient(90deg, #1b1b1b 10px, transparent 10px),
linear-gradient(#1d1d1d 25%, #1a1a1a 25%, #1a1a1a 50%, transparent 50%, transparent 75%, #242424 75%, #242424);
background-color: #131313;
background-size: 20px 20px;
width: 52%;
float: left;
border: 2px solid #354350;
border-radius: 5px;
-moz-border-radius: 5px;    
height: 400px;
margin: 5px;
padding: 5px;
}

I can't even imagine how can this be done, but I've seen such feature in e107's news system. 我什至无法想象如何做到这一点,但是我已经在e107的新闻系统中看到了这种功能。

Your help would be appreciated. 您的帮助将不胜感激。

Instead of using height , try min-height instead: 不要使用height ,而是尝试使用min-height

#centercol {
  ...
  min-height: 400px;
  ...
}

I think the property name itself is self-explanatory. 我认为属性名称本身是不言而喻的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM