为什么iconfont不受text-align的影响
来源:1-5 项目作业
xcn_aaaa
2023-04-03 16:55:45
<template>
<div class="wrapper">
<div class="header">
<div class="header__back iconfont"></div>
<div class="header__title">管理收货地址</div>
<div class="header__new">新建</div>
</div>
<div class="address">
<div class="address__title">我的收获地址</div>
</div>
</div>
</template>
<script>
export default {
name: 'Address'
}
</script>
<style lang="scss" scoped>
.wrapper {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #eee;
}
.header {
display: flex;
padding: 0 .18rem;
line-height: .44rem;
background-color: #fff;
margin-bottom: .16rem;
&__back {
text-align: left;
color: #b6b6b6;
font-size: .24rem;
width: .2rem;
height: .44rem;
}
&__title {
flex: 1;
font-size: .16rem;
width: 2.8rem;
color: #333333;
text-align: center;
}
&__new {
width: .28rem;
height: .44rem;
font-size: 14px;
color: #333333;
}
}
.address {
padding: 0 .18rem;
&__title {
font-size: 14px;
color: #333333;
}
}
</style>1回答
同学你好,iconfont受text-align影响。由于字体图标所在父元素header__back的宽度设置太小了,所以text-align看上去没效果。将父元素宽度增大就能看出来了:

祝学习愉快!
相似问题