Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用html确定div是否隐藏了溢出?_Html_Angular_Wep - Fatal编程技术网

如何使用html确定div是否隐藏了溢出?

如何使用html确定div是否隐藏了溢出?,html,angular,wep,Html,Angular,Wep,如何使用html确定div是否有溢出隐藏? 使用Ngif我不想在类型脚本代码中使用它,如果div有溢出隐藏,我需要设置另一个属性 <div id="greetings" [innerHTML]="page.title"> </div> #greetings{ width: 100 px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } #问候{ 宽度:100像

如何使用html确定
div
是否有
溢出
隐藏
?
使用
Ngif
我不想在类型脚本代码中使用它,如果
div
溢出隐藏
,我需要设置另一个属性

<div id="greetings" [innerHTML]="page.title">
</div>

#greetings{
   width: 100 px;
   white-space: nowrap;
   overflow: hidden;
   text-overflow: ellipsis;
}

#问候{
宽度:100像素;
空白:nowrap;
溢出:隐藏;
文本溢出:省略号;
}

如何实现这一点?

存在一种通过在元素内部使用var来获取元素样式信息的方法,这种方法被命名为
#vars
它能够直接在元素中获取样式,这就是为什么我将atribute
style=“overflow:hidden”

请看以下示例:

<div id="greetings" style="overflow: hidden" #vars>
  <div *ngIf="(vars.style.overflow === 'hidden')">
      Hello universe!
  </div>
</div>

你好,宇宙!

这是一个

它已经隐藏了!或者,如果有隐藏的文本,则返回true!!我的意思是当这个条件返回真的时候*ngIf=“(vars.style.overflow==“hidden”)如果将
style=“overflow:hidden”
更改为例如
style=“overflow:auto”)“
它将消失,这只是一个示例,我只是告诉你如何直接比较html中的样式属性我只需要确定div是否有溢出,我的意思是它有title并隐藏溢出,因为存在div包含完整title的情况