HTML/CSS Text overflowing its container

前端 未结 3 834
面向向阳花
面向向阳花 2021-01-15 18:14

I\'ve been doing this simple page with a text field and two select fields, where I can choose a text color and a text size. I put some borders with diferent colors to each d

3条回答
  •  臣服心动
    2021-01-15 18:40

    Your div has a style of "display: inline;", Change that to "display: inline-block;"

    div
    {
        display:inline;
    }
    

    change to:

    div
    {
        display:inline-block;
    }
    

    Think of it this way. Inline elements aren't meant to contain block elements. For instance, a (which is an inline element) can span from the end of one line to the beginning of the other, so it has no well defined width or height:

    ..... ..... ..... ..... ..... ..... ..... Hello
    World  ..... ..... ..... ..... ..... ..... ...
    

    But you don't want to make it a block (or

    ) either because it takes up the whole line:

    Hello ..... ..... ..... ..... ..... .....
    World ..... ..... ..... ..... ..... .....

    So if you declare an element inline-block, you can have several blocks side-by-side

    Hello
    World

提交回复
热议问题