文本單行溢出顯示省略號
實現文本單行溢出顯示,需要給該文本的盒子加一定寬度
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
具體demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>lvyweb</title>
<style>
p{
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
width: 200px;
}
</style>
</head>
<body>
<p>實現文本單行溢出顯示,需要給該文本的盒子加一定寬度實現文本單行溢出顯示,需要給該文本的盒子加一定寬度</p>
</body>
</html>
文本單行溢出顯示省略號,鼠標懸停會顯示全部,hover的時候設置寬度auto
具體demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>lvyweb</title>
<style>
p{
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
width: 200px;
}
p:hover { width:auto; }
</style>
</head>
<body>
<p>實現文本單行溢出顯示,需要給該文本的盒子加一定寬度實現文本單行溢出顯示,需要給該文本的盒子加一定寬度</p>
</body>
</html>