css3文本省略换行,添加字体

<!DOCTYPE html>
<html>
<head>
<title>文本省略,添加字体</title>
<meta charset="utf-8">
<style type="text/css">
div{
font-family: myFont;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
/*做到文本溢出以省略号代替的效果是text-overflow: ellipsis来决定的,但是它需要overflow: hidden;
white-space: nowrap;来配合*/
}
/*font-family可以设置文本字体,比如font-family: "微软雅黑"等
如果想使用第三方字体就需要使用@font-face来创建自定义字体然后用font-family: myFont引用
字体是区分中文和英文的*/
@font-face{
font-family: myFont;
src:url("fonts/SingleMalta.ttf");
}

</style>
</head>
<body>
<div>can i use here hhhh hhhh hhhh hhhhh hhh kkkk kkkkk dad dasd wewe ewewe ewewds dad dsds</div>
</body>
</html>

原文地址:https://www.cnblogs.com/adialike/p/6383749.html