Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9267917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:40:24+00:00 2026-06-18T14:40:24+00:00

I have a php scrpit that creates a bunch of divs containing an image

  • 0

I have a php scrpit that creates a bunch of divs containing an image and some text. The div’s are floated so they all read from left to right. My problem is that when a browser is resized or viewed on a smaller screen size the div’s will float underneath each other, what you’d expect css to do but not what I want. If only 4 divs will fir on the screen then it should only display 4 divs. If 7 then 7. This is what it is currently doingenter image description here

And this is how it should look

enter image description here

What my code looks like

<div id="mainContent2">


                                    <div id="newReleaseDiv"><center><input type="image" img src="Images/Database Images//GALLO/7599385542.jpg" height="150px"  /></center>
                <span>Live -Frat Party At</span><br  />
                 <span> 
                 Linkin Park</span><br />
                <span>R 200.00</span>
                </div>
                                        <div id="newReleaseDiv"><center><input type="image" img src="Images/Database Images//GALLO/7599399935.jpg" height="150px"  /></center>
                <span>Road To Revolution:</span><br  />
                 <span> 
                 Linkin Park</span><br />
                <span>R 250.00</span>
                </div>
                                        <div id="newReleaseDiv"><center><input type="image" img src="Images/Database Images//GALLO/9362424712.jpg" height="150px"  /></center>
                <span>2 Points Of Authority</span><br  />
                 <span> 
                 Linkin Park</span><br />
                <span>R 100.00</span>
                </div>
                                        <div id="newReleaseDiv"><center><input type="image" img src="Images/Database Images//GALLO/9362426132.jpg" height="150px"  /></center>
                <span>Somewhere I Belong</span><br  />
                 <span> 
                 Linkin Park</span><br />
                <span>R 100.00</span>
                </div>
                                        <div id="newReleaseDiv"><center><input type="image" img src="Images/Database Images//GALLO/9362426302.jpg" height="150px"  /></center>
                <span>Faint (Single)</span><br  />
                 <span> 
                 Linkin Park</span><br />
                <span>R 100.00</span>
                </div>
                                        <div id="newReleaseDiv"><center><input type="image" img src="Images/Database Images//GALLO/9362483262.jpg" height="150px"  /></center>
                <span>Reanimation (Remix</span><br  />
                 <span> 
                 Linkin Park</span><br />
                <span>R 150.00</span>
                </div>
                                        <div id="newReleaseDiv"><center><input type="image" img src="Images/Database Images//GALLO/9362484622.jpg" height="150px"  /></center>
                <span>Meteora (Import)</span><br  />
                 <span> 
                 Linkin Park</span><br />
                <span>R 150.00</span>
                </div>
                                        <div id="newReleaseDiv"><center><input type="image" img src="Images/Database Images//GALLO/WBCD 1987.jpg" height="150px"  /></center>
                <span>Hybrid Theory</span><br  />
                 <span> 
                 Linkin Park</span><br />
                <span>R 100.00</span>
                </div>
                                        <div id="newReleaseDiv"><center><input type="image" img src="Images/Database Images//GALLO/WBCD 2024.jpg" height="150px"  /></center>
                <span>Reanimation (Remix Album)</span><br  />
                 <span> 
                 Linkin Park</span><br />
                <span>R 100.00</span>
                </div>
                                        <div id="newReleaseDiv"><center><input type="image" img src="Images/Database Images//GALLO/WBCD 2061.jpg" height="150px"  /></center>
                <span>Live In Texas</span><br  />
                 <span> 
                 Linkin Park</span><br />
                <span>R 100.00</span>
                </div>

</div>

There will be multiple divs on a page like this so what is the best solution here that if the browser is resized it will hide or show more divs without the page been reloaded and that is cross browser compatable

I used this script that worked in ff, chrome, opera but not IE. It would load the page correctly but when you resized the browser it wouldn’t hide or show more divs. You would have to reload the page again

<script type="text/javascript">
          function newReleaseDisplay () {
               if (width > 1000) {
       var divsToDisplay = Math.floor(width / 175);
       $("#mainContent2 > div").slice(1).show();
       $("#mainContent2 > div").slice(divsToDisplay).hide();
       }
       else {
            var divsToDisplay = Math.floor(1000 / 175);
            $("#mainContent2 > div").slice(1).show();
            $("#mainContent2 > div").slice(divsToDisplay).hide();

       }
      }
    var width = $(window).width();
    window.onload = newReleaseDisplay();

$(window).resize(function(){
   if($(this).width() != width){
      width = $(this).width();
       console.log(width);
       newReleaseDisplay ();
   }
});
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:40:26+00:00Added an answer on June 18, 2026 at 2:40 pm

    Just float all .newReleaseDiv left, and set #mainContent2 to have a fixed height of one row’s height and overflow: hidden;

    JavaScript isn’t really necessary here. CSS should be used for display/layout instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have php script that creates a temporary watermark image for users that are
Basically I have a PHP script that creates a div for each item in
I have a PHP script that creates a thumbnail and lists an image gallery.
I have a PHP script that creates a very tall image and draws a
I have a PHP script that creates large complex tables. I am attempting to
I have a PHP script that creates other PHP files based on user input.
Say I have a PHP script that creates a cookie that expires 10 days
I have a very simple script that creates a user: <?php include 'mysqlserver.php'; session_start();
I have a PHP script that creates an entry into a mysql database. The
I have a php script that creates csv files: header('Expires: 0'); header('Cache-control: private'); header('Cache-Control:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.