text-align: justify;适配问题

本文探讨了CSS中text-align-last属性的使用限制,特别是其对最后一行文本不生效的问题,并提供了解决方案,通过巧妙地添加额外内容来实现文本的完全居中。

text-align-last: justify;使用,有事不生效,因为对最后一行不生效,可以再加一行省略掉

针对这个Vue项目进行响应式布局调整,主要目标是让页面在不同设备上都能自适应显示:<template> <div class="family"> <!-- 顶部导航栏 --> <NavBar /> <!-- 首页内容区域 --> <div class="content-banner"> <hotel-reservation class="hotel-reservation"></hotel-reservation> </div> <div class="banner-text"> <p class="text" :class="{ textEn: $i18n.locale === 'en' }">{{ $t('Family') }}</p> <!-- <span class="top1" >Wedding Banquet & Conference</span> --> </div> <div class="content-wrapper"> <div class="title-box"> <p class="title-zh" :class="{ textEn: $i18n.locale === 'en' }">{{ $t('trip2') }}</p> </div> <!-- 一起脉动 --> <div class="content-box"> <div class="text-box"> <p class="content margin-bottom-20" :class="{ textEn: $i18n.locale === 'en' }"> {{ $t('text28') }} </p> <p class="more":class="{ textEn: $i18n.locale === 'en' }">{{ $t('more7') }}</p> </div> <div class="img-box"> <img src="@/assets/wedding/cup.png" alt="" /> </div> </div> <!-- 专业策划 --> <div class="content-box"> <div class="img-box"> <img src="@/assets/wedding/table.png" alt="" /> </div> <div class="text-box"> <p class="title-zh text-center" :class="{ textEn: $i18n.locale === 'en' }">{{ $t('Professional') }}</p> <p class="content margin-top-20" :class="{ textEn: $i18n.locale === 'en' }"> {{ $t('text20') }} </p> <p class="content"> </p> <p class="more div-center" :class="{ textEn: $i18n.locale === 'en' }">{{$t('more8')}}</p> </div> </div> <!-- 婚宴进行中 --> <div class="content-box"> <div class="text-box"> <p class="title-zh text-center" :class="{ textEn: $i18n.locale === 'en' }">{{ $t('progress') }}</p> <p class="content margin-top-20" :class="{ textEn: $i18n.locale === 'en' }"> {{ $t('text21') }} </p> <p class="more div-center" :class="{ textEn: $i18n.locale === 'en' }">{{ $t('more9') }}</p> </div> <div class="img-box"> <img src="@/assets/wedding/flower.png" alt="" /> </div> </div> </div> <!-- 底部导航栏 --> <Footer /> </div> </template> <script> export default { name: "family", data() { return { }; }, }; </script> <style scoped> .content-banner { width: 100vw; height: 62rem; margin: 0 auto; background-image: url("@/assets/wedding/flower.png"); background-size: 100% 100%; position: relative; } .hotel-reservation { width: 120rem; height: 12rem; margin: 0 auto; position: relative; top: 45rem; } .content-wrapper { width: 120rem; margin: 0 auto; } .title-box { text-align: center; margin: 6rem 0; } .content-box { display: flex; justify-content: space-between; margin-bottom: 10rem; } .title-en{ font-size: 3rem; font-weight: bold; line-height: 2em; font-family: "Times New Roman", Times, serif; } .textEn { font-family: "Times New Roman", Times, serif !important; } .banner-text { position: absolute; top: 10rem; left: 20%; padding: 1rem 24rem; font-size: 3.2rem; line-height: 2em; font-weight: bold; color: #fff; text-align: center; background-color: rgba(1, 1, 1 1.5); } .text { margin-top: 2rem; font-family: "FangSong"; font-size: 10rem; line-height: 2em; text-align: left; padding: 0 4rem; text-align: justify; -webkit-text-justify: inter-word; text-justify: inter-word; } .top1{ font-family: "Times New Roman", Times, serif; font-size: 6rem; font-weight: bold; } .title-zh { font-size: 4.6rem; /* font-weight: bold; */ color: rgb(202, 171, 98); text-align: left; } .content { width: 60rem; font-size: 2rem; line-height: 2; font-family: "Fangsong"; text-align: justify; } .img-box img { width: 50rem; height: 30rem; } .more { width: 15rem; font-size: 2rem; line-height: 2em; color: rgb(202, 171, 98); text-align: center; cursor: pointer; background-color: rgb(238, 235, 235); } .text-box{ text-align: left; } /* 通用属性 */ /* 文本居中 */ .text-center { text-align: left; } /* div居中 */ .div-center { margin: 5rem auto; text-align: center; } /* 上外边距2rem */ .margin-top-20 { margin-top: 2rem; } /* 下外边距2rem */ .margin-bottom-20 { margin-bottom: 2rem; } /* 页面修改区域 */ /* 响应式调整 */ @media screen and (max-width: 1024px) { .content-banner { height: 70rem; } .hotel-reservation { width: 160rem; top: 54rem; } .content-wrapper { width: 160rem; } .title-en { font-size: 4.8rem; } .title-zh { font-size: 5.6rem; } .content { width: 74rem; font-size: 3rem; } .img-box{ width: 54rem; height: 42rem; } .img-box img { width: 54rem; height: 42rem; } .more { width: 20rem; font-size: 2.4rem; } } @media screen and (max-width: 768px) { .content-banner { height: 82rem; background-image: url("@/assets/wedding/flower.png"); } .hotel-reservation { width: 160rem; top: 66rem; } .content-wrapper { width: 160rem; } .content-box { flex-direction: column; } .img-box { order: 2; } .img-box img { width: 100rem; height: auto; } .text-box { order: 1; } .title-en { font-size: 6rem; } .title-zh { font-size: 6.2rem; } .content { width: 160rem; font-size: 4rem; } .img-box { width: 160rem; height: 90rem; } .more { width: 30rem; font-size: 3.2rem; margin-bottom: 5rem; margin-left: 130rem; } } </style>
07-05
现在收起图标在下一行颜色是灰色居左,我需要居右和展开图标对其,颜色一样.videoSummaryH5 { background: rgba(0, 65, 211, 0.05); padding: 8px 24px; line-height: 1.5; font-size: 14px; } .svg { font-size: 16px; margin-right: 4px; } .summaryH5Notice { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; } .summaryH5Right, .summaryH5Left { display: flex; align-items: center; } .summaryH5Left { color: #0041d3; } /* 三行截断,单词不断开 */ .summaryH5Clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; /* 精确控制 */ font-size: 14px; line-height: 20px; max-height: 60px; overflow: hidden; text-overflow: ellipsis; word-break: break-word; box-sizing: border-box; /* 防止外部样式干扰 */ white-space: normal; margin: 0; padding: 0; } /* 展开后:全文显示 */ .summaryH5Expanded { white-space: pre-wrap; overflow: visible; text-overflow: unset; display: block; } /* 容器定位图标 */ .summaryH5Container { position: relative; padding-right: 20px; } /* 展开/收起图标 */ .expandIcon { position: absolute; right: 0; bottom: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; z-index: 1; cursor: pointer; color: #0041d3; font-size: 12px; } /* 收起按钮:内联 vs 固定到底部 */ .foldButtonInline { position: relative; text-align: center; margin: 16px 0; } .foldButtonFixed { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: rgba(0, 65, 211, 0.1); padding: 4px 12px; border-radius: 20px; z-index: 1000; } /* 内容样式 */ .summaryContent { overflow-y: auto; border-radius: 0.8rem; padding-bottom: 1.6rem; width: 32rem; font-size: 1.4rem; line-height: 2.4rem; position: relative; } .summaryContentWidth { width: 28.8rem; } .label { color: #666666; margin-bottom: 4px; } .description, .keywords { color: #000000; text-align: justify; word-break: break-word; } .keywordsLabel { margin-top: 16px; } /* Panel 样式覆盖 */ .summaryContent :global .ev_Panel { margin-top: 24px; } .summaryContent :global .ev_Panel .ev_PanelItem:not(:first-child) { margin-top: 16px; } .summaryContent :global .ev_Panel .ev_PanelItem_title { flex-direction: row-reverse; justify-content: space-between; height: auto; } .summaryContent :global .ev_Panel .ev_PanelItem_title .ev_PanelItem_title_titleInfo { flex: 1; font-size: 14px; color: #666666; line-height: 24px; word-break: break-all; } .summaryContent :global .ev_Panel .ev_PanelItem .ev_PanelItem_title .ev_PanelItem_title_showChange { margin-right: 0; align-self: flex-start; margin-left: 4px; width: 24px !important; height: 24px !important; line-height: 24px !important; display: flex; align-items: center; justify-content: center; } .summaryContent :global .ev_Panel .ev_PanelItem .ev_PanelItem_title .panelHide { justify-content: flex-start; } .summaryContent :global .ev_Panel .ev_PanelItem .ev_PanelItem_title .panelShow { justify-content: flex-end; } .summaryContent :global .ev_Panel .ev_PanelItem .ev_PanelItem_title .ev_PanelItem_title_showChange > .ev_icon { display: flex; align-items: center; justify-content: center; } .summaryContent :global .ev_Panel .ev_PanelItem .ev_PanelItem_title .ev_PanelItem_title_showChange svg { width: 12px; height: 12px; } .summaryContent :global .ev_Panel .ev_PanelItem_container { padding: 0; margin-top: 6px; font-size: 14px; color: #000000; text-align: justify; line-height: 24px; } /* 时间标题样式 */ .summaryTitleBox { display: flex; } .summaryTimeItem { text-wrap: nowrap; margin-right: 8px; max-width: 60px; white-space: nowrap; } .summaryTitleItem { flex: 1; word-break: break-all; } /* 图标类 */ .operationIcon { margin-left: 12px; font-size: 18px; color: #666; } /* 英文适配 */ .summaryH5En .title { font-size: 12px; } .summaryH5En .operationIcon { margin-left: 8px; } /* 全局兼容 */ :global(.video-summary-h5 .summaryTest) { width: max-content !important; white-space: nowrap !important; max-width: max-content !important; }
11-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值