CSS 控制固定高度和寬度

來源:互聯網
上載者:User

一, 如需要固定高度及寬度,如下:

<div style='height:50px;width:205px;overflow:hidden;'>

....

</div>

關鍵點:overflow:hidden

用途:將超出部分文字就隱藏

二,如需固定寬度,但對超出長度的文字顯示省略符號,如下:

<div style='height:50px;width:205px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;'>

....

</div>

white-space:nowrap 表示不允許換行

text-overflow:ellipsis 表示顯示省略符號

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.