Two div blocks on same line

后端 未结 11 1164
小蘑菇
小蘑菇 2020-11-30 21:09

How to center on the same \"line\" two div blocks?

First div:

相关标签:
11条回答
  • 2020-11-30 21:43

    Use a table inside a div.

    <div>
       <table style='margin-left: auto; margin-right: auto'>
            <tr>
               <td>
                  <div>Your content </div>
               </td>
               <td>
                  <div>Your content </div>
               </td>
            </tr>
       </table>
    </div>
    
    0 讨论(0)
  • 2020-11-30 21:45

    Use Simple HTML

    <frameset cols="25%,*">
      <frame src="frame_a.htm">
      <frame src="frame_b.htm">
    </frameset>
    
    0 讨论(0)
  • 2020-11-30 21:47

    You can do this in many way.

    1. Using display: flex

    #block_container {
        display: flex;
        justify-content: center;
    }
    <div id="block_container">
      <div id="bloc1">Copyright &copy; All Rights Reserved.</div>
      <div id="bloc2"><img src="..."></div>
    </div>

    1. Using display: inline-block

    #block_container {
        text-align: center;
    }
    #block_container > div {
        display: inline-block;
        vertical-align: middle;
    }
    <div id="block_container">
      <div id="bloc1">Copyright &copy; All Rights Reserved.</div>
      <div id="bloc2"><img src="..."></div>
    </div>

    1. using table

    <div>
        <table align="center">
            <tr>
                <td>
                    <div id="bloc1">Copyright &copy; All Rights Reserved.</div>
                </td>
                <td>
                    <div id="bloc2"><img src="..."></div>
                </td>
            </tr>
        </table>
    </div>

    0 讨论(0)
  • 2020-11-30 21:47

    Use below Css:

    #bloc1,
    #bloc2 {
    display:inline
    } 
    
    body {
    text-align:center
    }
    

    It will make the mentioned 2 divs in the center on the same line.

    0 讨论(0)
  • 2020-11-30 21:48

    Try an HTML table or use the following CSS :

    <div id="bloc1" style="float:left">...</div>
    <div id="bloc2">...</div>
    

    (or use an HTML table)

    0 讨论(0)
  • 2020-11-30 21:51

    HTML File

     <div id="container">
          <div id="bloc1">Copyright &copy; All Rights Reserved.</div>
          <div id="bloc2"><img src="..."></div>
        </div>
    

    CSS File

     #container
        {
            text-align:center;
        }
        #bloc1, #bloc2
        {
            display:inline;
        }
    
    0 讨论(0)
提交回复
热议问题