DIV tag creating new line in php

后端 未结 5 1257
清歌不尽
清歌不尽 2021-01-29 00:20

I am trying to style results from database but when I echo

it is creating new line after each result. How can I force the div not to create a new line?<
相关标签:
5条回答
  • 2021-01-29 01:09

    you can either display the div as inline-block or set float: [left|right]

    Using inline style

    style="display: inline-block;"
    
    style="float: left;"
    

    using css

    .message {
       display: inline-block;
    }
    
    .message {
       float: left;
    }
    
    0 讨论(0)
  • 2021-01-29 01:17

    Consider using <span> instead of <div>

    <span> are already inline tags where <div> are blocks by default, which create a new line for the content in it.

    0 讨论(0)
  • 2021-01-29 01:20

    You create new DIVs every time. Every div by default starts with a new line.

    0 讨论(0)
  • 2021-01-29 01:20

    Use css property display:inline-block e.g.

    .message{
      border:2px solid;
      background-color:white;
      display:inline-block;
     }
    

    It will arrange your messages linearly.

    0 讨论(0)
  • 2021-01-29 01:22
    .message{
            border:2px solid;
            background-color:white;
            float:left;
            }
    

    try with above css will display in one line

    0 讨论(0)
提交回复
热议问题