text-justify: distribute;
时间: 2024-05-18 18:12:47 浏览: 10
`text-justify: distribute` 是CSS文本对齐属性的一种值。它用于在两端对齐的基础上,通过拉伸字符间距的方式来使文本均匀分布在一行中,从而实现更好的对齐效果。该属性只适用于文本对齐方式为两端对齐(text-align: justify)时才能生效。需要注意的是,该属性目前只有Chrome和Safari浏览器支持。
相关问题
text-align:justify两端对齐布局兼容ie
text-align:justify是一种常见的文本对齐方式,它会将文本段落两端对齐,让页面看起来更加整洁美观。但是,text-align:justify在IE浏览器中的兼容性不太好,具体原因是IE浏览器不支持text-justify属性。
为了兼容IE浏览器,我们可以使用一些hack技巧来实现text-align:justify布局。其中一个比较常见的方法是使用伪元素:before和:after来实现。具体实现方法如下:
```
p {
text-align: justify;
text-justify: distribute-all-lines; /* 兼容IE11及以下版本 */
}
p:before,
p:after {
content: "";
display: inline-block;
width: 100%;
height: 0;
}
```
在上面的代码中,我们给p元素设置了text-align:justify和text-justify:distribute-all-lines属性,然后通过:before和:after伪元素来实现两端对齐布局。
需要注意的是,这种hack技巧虽然能够在IE浏览器中兼容text-align:justify布局,但是会增加页面的代码量和复杂度,建议在实际应用中谨慎使用。
el-form-item中label文字超长
如果el-form-item中的label文字超长,可以通过设置css样式来解决。首先,在template中设置label时,可以使用"\n"来表示换行。比如:
```html
<el-form-item :label="'税收居民国(地区)2\n(如有请填写):'" class="foldLabel">
<el-input type="text"></el-input>
</el-form-item>
```
接下来,在css中设置样式,使label能够自动换行并与input等高。可以使用以下样式:
```css
<style scoped>
.el-form-item.foldLabel .el-form-item__label {
white-space: pre-line; /* 换行显示 */
height: 32px; /* 设置lable高度,与input高度一样 */
line-height: 16px!important; /* 设置行高为label高度的一半(有n行就是label高度的1/n) */
}
</style>
```
另外,如果需要对其他label进行样式设置,可以使用以下样式:
```css
/* 过于长的label分两行展示样式 */
.fold_label .el-form-item__label {
white-space: pre-line;
text-align-last: justify;
text-align: justify;
margin-top: -4px;
line-height: 25px;
text-justify: distribute-all-lines;
}
/* 其他label根据宽度自动撑开 */
.el-form-item__label {
text-align-last: justify;
text-align: justify;
text-justify: distribute-all-lines;
}
```
通过以上设置,可以使el-form-item中的label文字超长时自动换行,并与input等高。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)