Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想这样做:如果标签的文本宽度大于其容器的总宽度,则显示标签的子字符串,而不是显示完整标签的文本。在 c# 中:目前正在使用以下代码
if (SensorType.Text.Length >= 25) { SensorType.Text = SensorType.Text.Substring(0, 20) + "..."; }
它的工作,但它忽略像素或特定 .div 的区域是否有任何东西可以感知 div 像素
您可以使用 PURE CSS 来实现这一点...
刚刚设置
overflow:hidden; text-overflow: ellipsis;
请享用