Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Matching Div heights

Featured Replies

I have a code that is to match the height of two side by side div columns. The code I have does extend the shorter div however when its extended the two divs are not even as they should be any ideas how to fix this here is the code that I have.

 

matchColumns=function(){ 

    var divs,contDivs,maxHeight,divHeight,d; 

    divs=document.getElementsByTagName('div'); 

    contDivs=[]; 

    maxHeight=0;  

    for(var i=0;i<divs.length;i++){ 


         if(/\bcolumn\b/.test(divs[i].className)){ 

               d=divs[i]; 

               contDivs[contDivs.length]=d; 


               if(d.offsetHeight){ 

                    divHeight=d.offsetHeight; 					

               } 

               else if(d.style.pixelHeight){ 

                    divHeight=d.style.pixelHeight;					 

               } 

               maxHeight=Math.max(maxHeight,divHeight); 

         } 

    } 


    for(var i=0;i<contDivs.length;i++){ 

         contDivs[i].style.height=maxHeight + "px"; 

    } 

} 

window.onload=function(){ 

    if(document.getElementsByTagName){ 

         matchColumns();			 

    } 

}

Edited by Renaissance-Design
Please use the code button or tags to format your code.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.