css - 调整到较小的屏幕时,文本消失而不是换行
问题描述
当我调整屏幕大小时,我在尝试使我的文本换行时遇到了一些麻烦。出于某种原因,当我缩小屏幕时,文字没有换行,而是文字开始消失而不是换行。
js:
export default function About() {
return (
<>
<div className="about-hero">
<h1> Making your shopping experience more enjoyable.</h1>
</div>
</>
);
}
CSS:
*{
box-sizing: border-box
}
.about-hero {
background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.1)),
url("https://images.pexels.com/photos/301930/pexels-photo-301930.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
text-align: center;
color: #ffff;
height: 50vh;
line-height: 50vh;
}
.about-hero h1{
word-wrap: break-word;
}
解决方案
*{
box-sizing: border-box
}
.about-hero {
background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.1)),
url("https://images.pexels.com/photos/301930/pexels-photo-301930.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
text-align: center;
color: #ffff;
height: 50vh;
display: flex;
align-items: center;
justify-content: center;
}
<div class="about-hero">
<h1> Making your shopping experience more enjoyable.</h1>
</div>
推荐阅读
- javascript - 如何使用 jQuery 和 CSS 使侧边栏菜单和子菜单突出显示 onClick
- reactjs - 如何在 componentdidMount 之后再次渲染应用程序屏幕
- kubernetes - Airflow 1.10.7 中的 KubernetesPodOperator
- r - 为什么数据会这样表达?
- excel - 将一张纸的最后 3 个单元格相乘并将它们放在另一张纸中
- amazon-web-services - 一次使用单独的 Lambda 处理 AWS SQS 消息
- python - 使用 sqlalchemy-flask 在数据库中存储 XML 文件的最佳方法是什么?
- angular - 如何以角度修复“模块重复”
- podman - Podman 1.6 绑定挂载创建问题
- java - 在多个 JSP 页面中添加 ArrayList