CSS/PHP: How to make the next div appear on the side instead

Mark Te

I'm stuck on the project that I am doing right now. I made a php that outputs a single div, this div will output multiple times depending on the number of items that I have in my database, my problem is that, I want the next div to be outputted on the left side of the previous div, just like this:

 -----   -----   -----
|div 1| |div 2| |div 3|
 -----   -----   -----
 -----   -----   -----
|div 4| |div 5| |div 6|
 -----   -----   -----

But I can't think of any ways to do it, it's outputting as it should be like this:

 -----
|div 1|
 -----
 -----
|div 2|
 -----
 -----
|div 3|
 -----
and so on...

Hope you guys can help me, thanks.

PHP:

$results = $mysqli->query("SELECT * FROM content");
    if ($results) { 

    //fetch results set as object and output HTML
    while($obj = $results->fetch_object())
        {
        echo '<div class="content">'; 
        echo '</div>';
        }
    }

CSS:

.content{
    margin-bottom: 10px;
    height: 300px;
    background: #F0F0F0;
    padding: 10px;
    border: 1px solid #DDD;
    border-radius: 5px;
    box-shadow: 2px 2px 2px #F8F8F8;

}
Cattla

need a wrap div for class="content"

$results = $mysqli->query("SELECT * FROM content");
    if ($results) { 

    //fetch results set as object and output HTML
    while($obj = $results->fetch_object())
        {
        echo '<div class="box"><div class="content">'; 
        echo '</div></div>';
        }
    }

and the css

.box{
     width: 33.333333333%;
     box-sizing: border-box;
     float: left;
     }

here is demo http://jsfiddle.net/taunj8m0/2/

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

div going beneath instead of to the side

분류에서Dev

Two divs side by side: how can i make the div that is on the left side go down when it breaks for responsive layout?

분류에서Dev

How to make right side sidebar hover over the context of page instead of taking separate space

분류에서Dev

How to make a standalone application appear on the Mint menu?

분류에서Dev

Make paragraphs inside div continuously appear one by one using CSS

분류에서Dev

How to make a specific Tree Node to appear as a folder in a Tree View

분류에서Dev

How to make bullet holes appear in the background? (XNA C#)

분류에서Dev

How to make search results appear in a field under the search bar?

분류에서Dev

How to make a Dojox.dgauges indicator appear and disappear

분류에서Dev

How to make another key instead of replacing it in firebase

분류에서Dev

how to make to div in same row

분류에서Dev

How to put a custom image instead of checkbox next to text?

분류에서Dev

Content appear outside the div

분류에서Dev

How can I make a custom "POST" request on client side?

분류에서Dev

How to make table row at server side visible using javascript?

분류에서Dev

How to make a content div stretch from a header div to a footer div?

분류에서Dev

Make NAS appear as a USB drive

분류에서Dev

Select Dropbox value and appear at next text field

분류에서Dev

How make sidebar slide inside of a div and not the body?

분류에서Dev

how to vertically align image, that is next to div with dynamic height

분류에서Dev

How to make tmux count windows starting from 1 instead of 0?

분류에서Dev

How to make resolvconf append nameservers to the list instead of prepending them?

분류에서Dev

How to make div transition move on hover and reveal new div

분류에서Dev

How to make one div covering another div in different rows

분류에서Dev

How can I make appear a remove button on every LI in a Todo List?

분류에서Dev

How do i make a number appear in a text box after a button is pressed?

분류에서Dev

How to make a javascript or php SUCCESS message appear after optin form has been submitted

분류에서Dev

How can I make text appear when hovering a picture that has already the hovering for transform?

분류에서Dev

How can I make multiple physical hard drives appear as a single partition?

Related 관련 기사

  1. 1

    div going beneath instead of to the side

  2. 2

    Two divs side by side: how can i make the div that is on the left side go down when it breaks for responsive layout?

  3. 3

    How to make right side sidebar hover over the context of page instead of taking separate space

  4. 4

    How to make a standalone application appear on the Mint menu?

  5. 5

    Make paragraphs inside div continuously appear one by one using CSS

  6. 6

    How to make a specific Tree Node to appear as a folder in a Tree View

  7. 7

    How to make bullet holes appear in the background? (XNA C#)

  8. 8

    How to make search results appear in a field under the search bar?

  9. 9

    How to make a Dojox.dgauges indicator appear and disappear

  10. 10

    How to make another key instead of replacing it in firebase

  11. 11

    how to make to div in same row

  12. 12

    How to put a custom image instead of checkbox next to text?

  13. 13

    Content appear outside the div

  14. 14

    How can I make a custom "POST" request on client side?

  15. 15

    How to make table row at server side visible using javascript?

  16. 16

    How to make a content div stretch from a header div to a footer div?

  17. 17

    Make NAS appear as a USB drive

  18. 18

    Select Dropbox value and appear at next text field

  19. 19

    How make sidebar slide inside of a div and not the body?

  20. 20

    how to vertically align image, that is next to div with dynamic height

  21. 21

    How to make tmux count windows starting from 1 instead of 0?

  22. 22

    How to make resolvconf append nameservers to the list instead of prepending them?

  23. 23

    How to make div transition move on hover and reveal new div

  24. 24

    How to make one div covering another div in different rows

  25. 25

    How can I make appear a remove button on every LI in a Todo List?

  26. 26

    How do i make a number appear in a text box after a button is pressed?

  27. 27

    How to make a javascript or php SUCCESS message appear after optin form has been submitted

  28. 28

    How can I make text appear when hovering a picture that has already the hovering for transform?

  29. 29

    How can I make multiple physical hard drives appear as a single partition?

뜨겁다태그

보관