treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] weird behaviour of text with in a div !

  • create a div that pulls content from a database, i used the same type of div's on two different pages, on one of the page the data is absolutely fine. but on the other page the data keeps on overflowing in x direction.

    can anyone tell me whatz wrong with it !! ???

    <div class="left-philantropy">
    <?php
    foreach($myresult as $display) {

    echo "<p class='tagline'>".$display['title']."</p>";
    echo "<hr/>
    <br/>".$display['description']."<br/>";

    } ?>
    </div><!--left philantropy ends-->


    this is the php code i used to pull the data within left-philantropy div. and here is its css

    #philantropy .left-philantropy{
    width:500px;
    height:400px;
    padding:10px;
    float:left;
    position:relative;
    text-align:justify;
    overflow:auto;
    }
  • Would need to see how this goes on an actual site please. Could be a long string of text in the data, could be that the data contains HTML, etc.
  • i am still working on localhost, hvn't put it online !!! the only fix at the moment i could think is to make the text static instead of dynamic . and with static text its working absolutely fine !
  • Seems like problem is in the data, then...but can't say for sure until I see it in action.
  • well, everywhere i am pulling data from a database, the text keeps on running in x direction.. i am using the data type as "TEXT"
  • Try making the overflow hidden in the left-philantropy class. Also, what is your parent #philantropy and tagline class? Also, your position doesn't have to be relative if you are using floats.
  • #philantropy{
    width:990px;
    overflow:hidden;
    margin:auto;
    background:#dfeef3;
    }

    #philantropy p.tagline{
    font-size:55px;
    word-spacing:10px;
    color:#cbacaa;
    text-align:center;
    line-height:60px;
    }
    #philantropy .left-philantropy{
    width:500px;
    height:400px;
    padding:10px;
    float:left;
    position:relative;
    text-align:justify;
    overflow:auto;
    }



    this is how others are.
  • can you give us an example of the text that is being outputted by the script?