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 8363579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:12:44+00:00 2026-06-09T12:12:44+00:00

I found this neat tip on how to equally space divs within a container:

  • 0

I found this neat tip on how to equally space divs within a container:
Fluid width with equally spaced DIVs

I tried it out using static HTML and it works just fine:

<div class="category_area">
<div class="news_box shadow"><div class="inside"><h2><a href="#">Test</a></h2></div></div>
<div class="news_box shadow"><div class="inside">B</div></div>
<div class="news_box shadow"><div class="inside">C</div></div>
<div class="news_box shadow"><div class="inside">D</div></div>
<span class="stretch"></span></div>

And then I did this programatically with PHP:

<?php
echo "<div class='category_area'>";
for ($i=0;$i<4;$i++) {
    echo "<div class='news_box shadow'><div class='inside'><h2><a href='#'>Test</a></h2></div></div>";
}
echo "<span class='stretch'></span></div>";

However, the PHP version does not work although when I view the source through the browser the resulting HTML is identical. I am thinking this is because of the way PHP is rendered.

Here’s my CSS:

.category_area {
    text-align:justify;
    -ms-text-justify:distribute-all-lines;
    text-justify:distribute-all-lines;
}

.category_area .news_box {
    width:200px;
    height:250px;
    vertical-align:top;
    display:inline-block;
    *display:inline;
    zoom:1;
    background:#fff;
    padding:10px;
}

.category_area .news_box .inside {
    display:block;
}

.stretch {
    width:100%;
    display:inline-block;
    font-size:0;
    line-height:0;
}

.shadow {
    -moz-box-shadow: 3px 3px 4px #999;
   -webkit-box-shadow: 3px 3px 4px #999;
    box-shadow: 3px 3px 4px #999;
    /* For IE 8 */
    -ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#999999')";
    /* For IE 5.5 - 7 */
    filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='#999999');
}

Here’s how it looks when the source is viewed through the browser (static one):

<div class="category_area">
<div class="news_box shadow"><div class="inside"><h2><a href="#">Test</a></h2></div></div>
<div class="news_box shadow"><div class="inside">B</div></div>
<div class="news_box shadow"><div class="inside">C</div></div>
<div class="news_box shadow"><div class="inside">D</div></div>
<span class="stretch"></span></div>

PHP version:

<div class='category_area'><div class="news_box shadow"><div class="inside"><h2><a href="#">Test</a></h2></div></div><div class="news_box shadow"><div class="inside"><h2><a href="#">Test</a></h2></div></div><div class="news_box shadow"><div class="inside"><h2><a href="#">Test</a></h2></div></div><div class="news_box shadow"><div class="inside"><h2><a href="#">Test</a></h2></div></div><span class="stretch"></span></div>

Any tips on how to make this work?

  • 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-09T12:12:46+00:00Added an answer on June 9, 2026 at 12:12 pm

    You are missing whitespace (line breaks in your html sample) – which is one of the reasons I personally try to avoid any such inline-block workarounds.

    Adding a line break or a space would fix it for you:

    for ($i=0;$i<4;$i++) {
        echo "\r\n<div class='news_box shadow'><div class='inside'><h2><a href='#'>Test</a></h2></div></div>";
    }
    

    Or, for somewhat more readable (imo) markup:

    for ($i=0;$i<4;$i++) { ?>
      <div class="news_box shadow">
        <div class="inside">
          <h2><a href="#">Test</a></h2>
        </div>
      </div>
    <?php }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this neat command to merge multiple PDF into one, using Ghostscript: gs
From this question , a neat answer about using COALESCE to simplify complex logic
Howdy, I love this neat thing found on css-tricks: a:active { position: relative; top:
Found this while reading the Neo4j manual, specifically here , I found the sentence:
Found This: tyty stack, Social Icons not working with Infinite Scrolling on Wordpress I'm
found this little code snippet that seems to do what i want, but im
Found this Multimap containing pairs? , but it is not much help How would
Found this: Sub SurroundWithAppendTag() DTE.ActiveDocument.Selection.Text = .Append( + DTE.ActiveDocument.Selection.Text + ) End Sub But
found this regex: insert every 10 characters: $text = preg_replace(|(.{10})|u, \${1}. , $text); can
Found this rather strange bug in IE8; element.style.top is limited to 1342177 pixels. Even

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.