display:inline resets height and width

后端 未结 4 1361

I have created example at http://jsfiddle.net/GKnkW/2/

html




    Test
 <         


        
相关标签:
4条回答
  • 2020-11-30 11:39

    Just adding that I had a similar problem and thought it was a Javascript/Jquery issue. This thread solved for me.

    INLINE elements have no width, so you cannot set it via js.

    Thanks.

    Here's a link to my issue just in case.

    Jquery and Jqueryui: set width not working after using resizable?

    0 讨论(0)
  • 2020-11-30 11:45

    Inline objects don't have heights or widths. Why are you setting them inline to begin with? You probably want to either float them or use display: inline-block.

    0 讨论(0)
  • 2020-11-30 11:45

    Use this:

    display:inline-block;
    
    0 讨论(0)
  • 2020-11-30 11:47

    This should do it

    html

    <!DOCTYPE html>
    <html>
    <head>
        <title>Test</title>
     </head>
        <body>
          <div class="step-section">
              <div class="step">1</div>
              <div class="step">2</div>
          </div>
          <div class="step-section">
              <div class="step">3</div>
              <div class="step">4</div>
          </div>
    </body>
    </html> 
    

    css

    .step
    {
        margin:5px;
        height:150px;
        width:150px;    
        background: yellow;
        float:left;
    }
    
    .step-section
    {
      clear:both;
    }
    
    0 讨论(0)
提交回复
热议问题