当前位置: 首页 > news >正文

text-align的属性justify

text-align常用的属性是left、center、right,具体的可参考css解释,今天重点记录的对象是justify

justify 可以使文本的两端都对齐在两端对齐文本中,文本行的左右两端都放在父元素的内边界上。然后,调整单词和字母间的间隔,使各行的长度恰好相等

案例如下:

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title><style>.content {width: 600px;height: 200px;border: 3px solid red;text-align: justify;}.content1{text-align: left;}</style></head><body><div class="content">Shanghai is the largest city by population in the People's Republic ofChina (PRC) and the largest city proper by population in the world. It isone of the four province-level municipalities of the PRC, with a totalpopulation of over 23 million as of 2010. It is a global city, withinfluence in commerce, culture, finance, media, fashion, technology, andtransport. It is a major financial center and the busiest container portin the world.</div><div class="content content1">Shanghai is the largest city by population in the People's Republic ofChina (PRC) and the largest city proper by population in the world. It isone of the four province-level municipalities of the PRC, with a totalpopulation of over 23 million as of 2010. It is a global city, withinfluence in commerce, culture, finance, media, fashion, technology, andtransport. It is a major financial center and the busiest container portin the world.</div></body>
</html>

预览效果如下:

总结:

1、justify作用是使文本两端对齐

2、justify对元素没有效果,只对元素内文本生效

3、文本的最后一行或者使单独一行不生效

针对多行文本最后一行文本两端对齐不生效的处理方案

基本原则就是使最后一行的文本变成非最后一行

方案一:添加一行元素使其变为非最后一行

方案二:使用样式伪类的方法,使其变成非最后一行,推荐使用最后一种方式

案例如下:

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Document</title><style>.content {width: 600px;height: 200px;border: 3px solid red;text-align: justify;}.plan1{display:inline-block;width:100%;}.content::after{content: '';display:inline-block;width:100%;}</style></head><body><div class="content">Shanghai is the largest city by population in the People's Republic ofChina (PRC) and the largest city proper by population in the world. It isone of the four province-level municipalities of the PRC, with a totalpopulation of over 23 million as of 2010. It is a global city, withinfluence in commerce, culture, finance, media, fashion, technology, andtransport. It is a major financial center and the busiest container portin the world.<!-- <span class="plan1"></span> // 方案一 --></div></body>
</html>
http://www.lryc.cn/news/469595.html

相关文章:

  • 使用python自制桌面宠物,好玩!——枫原万叶桌宠,可以直接打包成exe去跟朋友炫耀。。。
  • 使用 ASP.NET Core 8.0 创建最小 API
  • 气候服务平台ClimateSERV2.0简介(python)
  • Docker | centos7上对docker进行安装和配置
  • React--》掌握Valtio让状态管理变得轻松优雅
  • python爬虫百度图片
  • 前端开发:Vue中数据绑定原理
  • CTF-RE 从0到N: TEA
  • python 使用PIL获取图片长宽
  • 【Nas】X-DOC:搞机之PVE部署All In One(黑群晖NAS 软路由OpenWrt Docker Win10远程桌面)
  • linux 驱动源码分析的理解。
  • 鸿蒙-任务栏右击退出 或 UIAbility窗口关闭,怎么弹框拦截
  • 【C++进阶篇】——STL的简介
  • 信息安全工程师(70)网络攻击陷阱技术与应用
  • Web保存状态的手段(Session的使用)
  • 第五十四章 安全元素的详细信息 - DerivedKeyToken 详情
  • kafka 的高可用机制是什么?
  • 4.1.3 网站通信技术
  • Java-图书管理系统
  • python如何通过json以及pickle读写保存数据
  • 【SPIE出版,EI检索稳定】2024年人机交互与虚拟现实国际会议(HCIVR 2024,11月15-17日)
  • Linux vim编辑器
  • 普推知产:申请商标名称从4字改成3字下了初审!
  • Flink 状态精准一次性特性
  • 算法笔记day08
  • 在Selenium中有哪些元素对象操作方法?( ̄﹃ ̄)
  • sqli-labs靶场安装以及刷题记录-docker
  • 谷歌仓库管理工具repo
  • C#的自定义Tip窗体 - 开源研究系列文章
  • 目前最新 Reflector V11.1.0.2067版本 .NET 反编译软件