DIV

2010-11-02 15 views
13

के लिए गतिशील ऊंचाई मैं निम्नलिखित DIVDIV

<div id="products"> 

</div> 

#products 
{ 
    height: 102px; width: 84%; 
    padding:5px; margin-bottom:8px; 
    border: 1px solid #EFEFEF; 
} 

अब DIV के अंदर है, मैं गतिशील 4 लिंक पैदा कर रहा हूँ। लेकिन कभी-कभी 4 से अधिक लिंक हो सकते हैं। मैं अपनी सामग्री के अनुसार डीआईवी गतिशील रूप से आकार बदलने के लिए सीएसएस कैसे बदल सकता हूं?

उत्तर

30

height: auto; सेट आप तो आप auto को

height:auto; 
min-height:30px; 
height:auto !important;  /* for IE as it does not support min-height */ 
height:30px;     /* for IE as it does not support min-height */ 
1

आपको सीएसएस से ऊंचाई संपत्ति लेने के लिए ठीक होना चाहिए।

1

दोनों सेट लिख सकते हैं एक्स के लिए न्यूनतम ऊंचाई करना चाहते हैं:

height: auto; 
width: auto; 

यह करना:

#products 
{ 
    height: auto; 
    width: auto; 
    padding:5px; margin-bottom:8px; 
    border: 1px solid #EFEFEF; 
} 
1

गणना प्रत्येक लिंक की ऊंचाई यह

document.getElementById("products").style.height= height_of_each_link* no_of_link 
1

पूर्व उत्तर के रूप में ऊंचाई attrib को हटा दें। यदि u इसकी मिनट ऊंचाई के साथ अपने विस्तार चाहते हैं तो height: 102px.

टिप्पणी यानी 6 और न्यूनतम-ऊंचाई http://www.dustindiaz.com/min-height-fast-hack/

2

यह
html-

<div style="background-color: #535; width: 100%; height: 80px;"> 
     <div class="center"> 
      Test <br> 
      kumar adnioas<br> 
      sanjay<br> 
      1990 
     </div> 
    </div> 

सीएसएस जैसे- मेरे लिए काम किया के बजाय min-height: 102px का उपयोग -

.center { 
    position: relative; 
    left: 50%; 
    top: 50%; 
    height: 82%; 
    transform: translate(-50%, -50%); 
    transform: -webkit-translate(-50%, -50%); 
    transform: -ms-translate(-50%, -50%); 
    } 

आशा आपकी भी मदद करेगी।