How to fix the height of a
element?

前端 未结 4 1743
庸人自扰
庸人自扰 2021-02-02 07:31

I\'ve defined my div\'s height in a stylesheet:

.topbar{
  width:100%;
  height:70px;
  background-color:#475;
}

But as soon as text is entered

相关标签:
4条回答
  • 2021-02-02 08:06

    change the div to display block

    .topbar{
        display:block;
        width:100%;
        height:70px;
        background-color:#475;
        overflow:scroll;
        }
    

    i made a jsfiddle example here please check

    http://jsfiddle.net/TgPRM/

    0 讨论(0)
  • 2021-02-02 08:10

    You can also use min-height and max-height. It was very useful for me

    0 讨论(0)
  • 2021-02-02 08:16

    You can try max-height: 70px; See if that works.

    0 讨论(0)
  • 2021-02-02 08:19

    If you want to keep the height of the DIV absolute, regardless of the amount of text inside use the following:

    overflow: hidden;
    
    0 讨论(0)
提交回复
热议问题