张家港网站建设优化,wordpress无法访问站点,漂亮大气网站,网站建设宣传语怎么写text-align常用的属性是left、center、right#xff0c;具体的可参考css解释#xff0c;今天重点记录的对象是justify
justify 可以使文本的两端都对齐在两端对齐文本中#xff0c;文本行的左右两端都放在父元素的内边界上。然后#xff0c;调整单词和字母间的间隔#x…text-align常用的属性是left、center、right具体的可参考css解释今天重点记录的对象是justify
justify 可以使文本的两端都对齐在两端对齐文本中文本行的左右两端都放在父元素的内边界上。然后调整单词和字母间的间隔使各行的长度恰好相等
案例如下:
!DOCTYPE html
html langenheadmeta charsetUTF-8 /meta nameviewport contentwidthdevice-width, initial-scale1.0 /titleDocument/titlestyle.content {width: 600px;height: 200px;border: 3px solid red;text-align: justify;}.content1{text-align: left;}/style/headbodydiv classcontentShanghai is the largest city by population in the Peoples 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./divdiv classcontent content1Shanghai is the largest city by population in the Peoples 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 langenheadmeta charsetUTF-8 /meta nameviewport contentwidthdevice-width, initial-scale1.0 /titleDocument/titlestyle.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/headbodydiv classcontentShanghai is the largest city by population in the Peoples 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 classplan1/span // 方案一 --/div/body
/html