search

Home  >  Q&A  >  body text

javascript - How to make the outer div adaptively adjust its width according to the width of the inner div

It is best to use pure html css, pseudo code example:

<p id="1">
    <p id="2"></p>
    <p id="3">
        <ul></ul>
    </p>
</p>

Let the width of the outer layer p1 change with the width of the inner layer p

PHP中文网PHP中文网2740 days ago956

reply all(3)I'll reply

  • 迷茫

    迷茫2017-06-26 11:00:30

    Thanks for the invitation.

    <style>
    #a {
        border: 1px solid red;
        display: inline-block;
    }
    
    #b {
        border: 1px solid green;
        margin: 2px 2px 2px 2px;
        height: 50px;
        width: 500px;
    }
    </style>
    <p id="a">
        <p id="b"></p>
        <p id="c">
            <ul></ul>
        </p>
    </p>

    reply
    0
  • PHP中文网

    PHP中文网2017-06-26 11:00:30

    <style>
     #1 {
      display: inline-block;
     }
    </style>

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-06-26 11:00:30

    #1{
       float:left;
    }

    reply
    0
  • Cancelreply