Html 填充区域中显示的隐藏内容溢出,是否可以隐藏? div{填充:5px;溢出:隐藏;高度:20px} 有些东西

Html 填充区域中显示的隐藏内容溢出,是否可以隐藏? div{填充:5px;溢出:隐藏;高度:20px} 有些东西,html,css,overflow,Html,Css,Overflow,小提琴: 在CSS中,是否可以在不添加其他层的情况下将文本隐藏在填充区域中?是的,我会使用边框而不是填充。像这样: <style> div{padding:5px;overflow:hidden;height:20px} </style> <div class="container"> something something something something something something something somethi

小提琴:


在CSS中,是否可以在不添加其他层的情况下将文本隐藏在填充区域中?

是的,我会使用边框而不是填充。像这样:

<style>
   div{padding:5px;overflow:hidden;height:20px}
</style>
<div class="container">
  something something   something something   something something   something something   something something   something something   something something 
<div>

我想plz给了div一个宽度

div{
border:solid 5px #00f;
overflow:hidden;
height:20px
}

div{填充:5px;溢出:隐藏;高度:40px;宽度:250px;背景:#009}

您可以通过使用边框而不是填充来解决此问题

 <style>
   div{padding:5px;overflow:hidden;height:40px; width:250px; background:#009}
</style>

查看更新的问题中的工作原理。请看小提琴。看起来您可能必须结束使用透明边框(其厚度等于填充物)并移除填充物。
div {
   border: 5px solid blue;
   overflow: hidden;
   background-color: blue;
   height: 40px
}