大家都知道单行文字水平垂直居中怎么设置,那么多行文字呢?
另外加上超出文本显示省略号。
单行文字
<!-- 单行文字 -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#div1 {
width: 300px;
height: 300px;
background: red;
text-align: center;
line-height: 300px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div id="div1">啊说得来看法塑料袋放进阿斯兰的感觉案例啊速度更快萨拉丁尬死了</div>
</body>
</html>
多行文字
这里使用了最常用的flex布局来实现。
想要实现超出省略号要借助于js,以后有时间再补。
<!-- 多行文字 -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#div1 {
width: 300px;
height: 300px;
background: red;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
</style>
</head>
<body>
<div id="div1">
<div>俺是个发射点发射点发请问撒大噶撒旦发生大噶山豆根</div>
<div>撒旦发射点发射点发</div>
<div>啊手动阀手动阀去问他十多个撒大噶山豆根企鹅人噶撒旦发多少</div>
</div>
</body>
</html>
记录记录!