目录
(1)默认值,baseline基线对齐,是英文字母的基本对齐方式
(2)top顶端对齐
(3)bottom底部对齐
(4)middle中间对齐,参考值是小写字母x的中间位置(此设置方式某些情况可能与baseline效果相同)
像素大小,例如100px,向上对齐100px
(1)left左对齐
(2)right右对齐
(3)center居中对齐
(4)justify两边对齐,文本对齐常用方式(符合写文章的格式)
(1)overline上划线
(2)underline下划线
(3)line-through删除线
(4)none多用于删除a链接下划线
(1)normal正常
(2)nowrap不换行
(3)pre保留换行与空白,用于匹配代码格式中的文本
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- 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>文本样式title>
- <style>
- div{
- border: solid red 1px;
- font-size: 40px;
- }
- span{
- /* vertical-align(垂直文本对齐方式):
- baseline基线对齐,多见于字母的对齐
- top顶端对齐
- bottom底部对齐
- middle中间对齐,是小写x的中间
- 或者以像素大小,例如100px,向上对齐100px
- */
- font-size: 20px;
- border: solid blue 1px;
- vertical-align: baseline;
- }
- p{
- /*
- text-align(文本对齐方式):
- left左对齐
- right右对齐
- center居中对齐
- justify两边对齐(符合写文章的格式)
-
- */
- border: 1px solid black;
- width: 400px;
- /* text-align: justify; */
- text-align: right;
- }
- style>
- head>
- <body>
- <div>This is an<span>applespan>! But you can't eat itdiv>
- <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Sit ratione unde nemo dolores vitae, doloribus eos veritatis quaerat iste pariatur natus suscipit, debitis commodi ut, nulla culpa voluptatibus aperiam consequatur!p>
-
- body>
- html>
- 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>文本样式2title>
- <style>
- .box1{
- /* 将多余字体省略不显示并增加省略号的方法 */
- width: 200px;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- /*
- white-space(空白格):
- 1.normal正常
- 2.nowrap不换行
- 3.pre保留换行与空白,用于匹配代码中的文本
- */
- }
- .box2{
- /*
- txt-decoration可选值:
- 1.overline上划线
- 2.underline下划线
- 3.line-through删除线
- */
- text-decoration: line;
- }
- .box3{
- white-space: pre;
- }
- style>
- head>
- <body>
- <div class="box1">Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestiae, recusandae voluptatibus, sed iusto quia dolores nam veniam sunt, natus praesentium architecto corrupti officiis omnis eius reprehenderit ratione est ea ipsam!div>
- <div class="box2">hello i'm li huadiv>
- <div class="box3">hello shit
- aa
- aa
- aa
- div>
- body>
- html>