Connecting Tech Pros Worldwide Forums | Help | Site Map

Css Hide show problem

Newbie
 
Join Date: Oct 2008
Posts: 1
#1: Oct 21 '08
i have the images i want it to display down of the list only .Please some one help me


Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3.  
  4. <html>
  5. <head>
  6.  
  7. <style type="text/css">
  8.  
  9. body{
  10.     font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif;    /* Font to use */
  11.     margin:0px;
  12.  
  13. }
  14.  
  15. .dhtmlgoodies_question{    
  16.     /* Start layout CSS */
  17.  
  18.     color:#FFF;
  19.     font-size:0.9em;
  20.     background-color:#F46200;
  21.     width:200px;
  22.     margin-bottom:2px;
  23.     margin-top:2px;
  24.     padding-left:2px;
  25.  
  26.     background-repeat:no-repeat;
  27.     background-position:top right;    
  28.     height:20px;
  29.     overflow:hidden;
  30.     cursor:pointer;
  31.     position:inherit;
  32.     float:left;
  33. }
  34. .img{    /* Parent box of slide down content */
  35.     /* Start layout CSS */
  36.  
  37.     border:1px solid #317082;
  38.     background-color:#E2EBED;
  39.     width:400px;
  40.  
  41.     /* End layout CSS */
  42.  
  43.     visibility:hidden;
  44.     height:0px;
  45.     overflow:hidden;
  46.     position:relative;
  47.     width:300;
  48.  
  49.  
  50. }
  51. .dhtmlgoodies_answer_content{    /* Content that is slided down */
  52.     padding:1px;
  53.     font-size:0.9em;    
  54.     position:relative;
  55.     cursor:default;
  56.  
  57. }
  58.  
  59.  
  60.  
  61. </style>
  62. <script type="text/javascript">
  63.  
  64. var dhtmlgoodies_slideSpeed = 10;    // Higher value = faster
  65. var dhtmlgoodies_timer = 10;    // Lower value = faster
  66.  
  67. var objectIdToSlideDown = true;;
  68. var dhtmlgoodies_activeId = false;
  69. var dhtmlgoodies_slideInProgress = false;
  70. function showHideContent(e,inputId)
  71. {
  72.     if(dhtmlgoodies_slideInProgress)return;
  73.     dhtmlgoodies_slideInProgress = true;
  74.     if(!inputId)inputId = this.id;
  75.     inputId = inputId + '';
  76.     var numericId = inputId.replace(/[^0-9]/g,'');
  77.     var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);
  78.  
  79.     objectIdToSlideDown = false;
  80.  
  81.     if(!answerDiv.style.display || answerDiv.style.display=='none'){        
  82.         if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId){            
  83.             objectIdToSlideDown = numericId;
  84.             slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));
  85.         }else{
  86.  
  87.             answerDiv.style.display='block';
  88.             answerDiv.style.visibility = 'visible';
  89.  
  90.             slideContent(numericId,dhtmlgoodies_slideSpeed);
  91.         }
  92.     }else{
  93.         slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));
  94.         dhtmlgoodies_activeId = false;
  95.     }    
  96. }
  97.  
  98. function slideContent(inputId,direction)
  99. {
  100.  
  101.     var obj =document.getElementById('dhtmlgoodies_a' + inputId);
  102.     var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);
  103.     height = obj.clientHeight;
  104.     if(height==0)height = obj.offsetHeight;
  105.     height = height + direction;
  106.     rerunFunction = true;
  107.     if(height>contentObj.offsetHeight){
  108.         height = contentObj.offsetHeight;
  109.         rerunFunction = false;
  110.     }
  111.     if(height<=1){
  112.         height = 1;
  113.         rerunFunction = false;
  114.     }
  115.  
  116.     obj.style.height = height + 'px';
  117.     var topPos = height - contentObj.offsetHeight;
  118.     if(topPos>0)topPos=0;
  119.     contentObj.style.top = topPos + 'px';
  120.     if(rerunFunction){
  121.         setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer);
  122.     }else{
  123.         if(height<=1){
  124.             obj.style.display='none'; 
  125.             if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
  126.                 document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block';
  127.                 document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible';
  128.                 slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed);                
  129.             }else{
  130.                 dhtmlgoodies_slideInProgress = false;
  131.             }
  132.         }else{
  133.             dhtmlgoodies_activeId = inputId;
  134.             dhtmlgoodies_slideInProgress = false;
  135.         }
  136.     }
  137. }
  138.  
  139.  
  140.  
  141. function initShowHideDivs()
  142. {
  143.     var divs = document.getElementsByTagName('DIV');
  144.     var divCounter = 1;
  145.     for(var no=0;no<divs.length;no++){
  146.         if(divs[no].className=='dhtmlgoodies_question'){
  147.             divs[no].onclick = showHideContent;
  148.             divs[no].id = 'dhtmlgoodies_q'+divCounter;
  149.             var answer = divs[no].nextSibling;
  150.             while(answer && answer.tagName!='DIV'){
  151.                 answer = answer.nextSibling;
  152.             }
  153.             answer.id = 'dhtmlgoodies_a'+divCounter;    
  154.             contentDiv = answer.getElementsByTagName('DIV')[0];
  155.             contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px';     
  156.             contentDiv.className='dhtmlgoodies_answer_content';
  157.             contentDiv.id = 'dhtmlgoodies_ac' + divCounter;
  158.             answer.style.display='none';
  159.             answer.style.height='1px';
  160.             divCounter++;
  161.         }        
  162.     }    
  163. }
  164. window.onload = initShowHideDivs;
  165. </script>
  166. </head>
  167. <body>
  168.  
  169.  
  170. <div  align="left" class ="dhtmlgoodies_question">New Products</div>
  171.  
  172.     <div id="img">
  173.     <div class="dhtmlgoodies_answer">
  174.         <img src="images2.jpg"/>
  175.         <img src="images6.jpg"/>
  176.         </div>
  177.  
  178.     </div>
  179. <div align="left" class="dhtmlgoodies_question">Hot Products</div>
  180.  
  181.     <div class="dhtmlgoodies_answer">
  182.     <div  id="Hot Products">
  183.         <img src="images1.jpg"/>
  184.         <img src="images5.jpg"/>
  185.     </div>
  186.     </div>
  187.  
  188. <div align="left" class="dhtmlgoodies_question">Comming soon</div>
  189.  
  190.     <div class="dhtmlgoodies_answer">
  191.     <div  id="coming soon">
  192.         <img src="images3.jpg"/>
  193.         <img src="images4.jpg"/>
  194.     </div>
  195.     </div>
  196.  
  197. </body>
  198. </html>

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,947
#2: Oct 21 '08

re: Css Hide show problem


Hey there, Anu and welcome to the forums.

When posting code on the forums, be sure to use [code] tags. [code] .. code goes here [/code]. If you neglect to do so, you will be given a warning and possibly a temporary ban. Please read the Posting Guidelines on How To Ask A Question

Markus.
Reply