Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将div样式设置为“最大高度”_Javascript_Html_Css_Styles - Fatal编程技术网

Javascript 将div样式设置为“最大高度”

Javascript 将div样式设置为“最大高度”,javascript,html,css,styles,Javascript,Html,Css,Styles,我有一个关于css样式的问题,我想将“最大高度”设置为“外部”。当我只设置高度时,效果很好,但当我想将其设置为最大高度时,内部内容将消失 您可以在此处获得示例: 有什么建议吗 //outer div style div.dogodkiinhalt { position: relative; top: 0px; left: 0px; width: 400px; padding-bottom: 0px;

我有一个关于css样式的问题,我想将“最大高度”设置为“外部”。当我只设置高度时,效果很好,但当我想将其设置为最大高度时,内部内容将消失

您可以在此处获得示例:

有什么建议吗

//outer div  style
 div.dogodkiinhalt {  
      position: relative; 
      top: 0px;   
      left: 0px;   
      width: 400px;  
      padding-bottom: 0px;
      background: blue; 
      border: none;  
      overflow: auto; 
      visibility: visible; 
      height: 200px;

    }
//inner div style
    #inhaltbox { 
      position: absolute;
      top: 0px; 
      overflow: hidden;
      width: 400px;
      height: 200px;
      display: none;
      display: block;
    }

是,如果您设置了
最大高度
-最小高度是多少?零

您还需要设置
min height
height

此外,这里还有一些问题

 div.dogodkiinhalt {  
      position: relative; 
      top: 0px;   <-- not needed
      left: 0px;   <--- not needed
      width: 400px;  
      padding-bottom: 0px;
      background: blue; 
      border: none;  
      overflow: auto; 
      visibility: visible; <--- not needed 
      height: 200px;

    }
//inner div style
    #inhaltbox { 
      position: absolute;
      top: 0px; <--- left or right also needs to be declared
      overflow: hidden;
      width: 400px;
      height: 200px;
      display: none;  <---
      display: block; <--- Choose one, not both
    }
div.dogodkiinhalt{
位置:相对位置;

顶部:0px;是,如果设置
最大高度
-最小高度是多少?零

您还需要设置
min height
height

此外,这里还有一些问题

 div.dogodkiinhalt {  
      position: relative; 
      top: 0px;   <-- not needed
      left: 0px;   <--- not needed
      width: 400px;  
      padding-bottom: 0px;
      background: blue; 
      border: none;  
      overflow: auto; 
      visibility: visible; <--- not needed 
      height: 200px;

    }
//inner div style
    #inhaltbox { 
      position: absolute;
      top: 0px; <--- left or right also needs to be declared
      overflow: hidden;
      width: 400px;
      height: 200px;
      display: none;  <---
      display: block; <--- Choose one, not both
    }
div.dogodkiinhalt{
位置:相对位置;

top:0px;同时使用:height和max height。这在什么浏览器中起作用?在mac或win上的firefox上是一样的。同时使用:height和max height。这在什么浏览器中起作用?在mac或win上的firefox上是一样的。好的,但是我如何设置div容器的高度以适应文本?你知道……如果我输入的文本较少than conatainers height必须小于它。我如何设置它?@greg你有文本开始吗?听起来好像当你经历了消隐DIV时,里面什么都没有。对吗?因为如果你只有
max height
(而不是
min height
height
)那么你的DIV应该只和里面的内容一样高。好吧,但是我如何设置DIV容器的高度以适应文本?你知道……如果我输入的文本少于conatainers,那么高度必须比它小。我如何设置呢?@greg你有什么文本可以开始吗?听起来好像当你经历了你的disapearing DIV时,你什么都没有n正确吗?因为如果您只有
最大高度
(而不是
最小高度
高度
),那么您的DIV应该与其中的内容一样高。