javascript - CSS垂直对齐部分标签中的文本?
问题描述
我发布了一个我正在做的例子
.open-text {
color: pink;
/*border: 1px solid red;*/
/* display: flex !important; */
/* align-items: center !important; */
background: #1e3a87;
font-family: 'Open Sans Condensed', sans-serif;
/*justify-content: center;*/
}
<section>
<h1 class="open-text">
<br/>
Lorem Ipsum: usage. Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder (or filler) text.your life.
</h1>
</section>
如何将文本放在中心并使其成为一个居中的列,其宽度不会占据整个页面?
解决方案
您对作品的尝试display: flex
,只需删除<br/>
(我还添加了一个height
,因此您可以看到它居中):
.open-text {
color: pink;
display: flex;
align-items: center;
background: #1e3a87;
font-family: 'Open Sans Condensed', sans-serif;
height:200px;
}
<section>
<h1 class="open-text">
Lorem Ipsum: usage. Lorem ipsum is a pseudo-Latin text used in web design, typography, layout, and printing in place of English to emphasise design elements over content. It's also called placeholder (or filler) text.your life.
</h1>
</section>
推荐阅读
- java - 如何制作实时滴答线图(MpandroidChart)?
- angular - Angular:在 ng-zorro 模态中路由
- c# - 使用带有 EFCore5.0 错误 System.InvalidOperationException 的存储过程
- javascript - 移动设备上 document.scrollingElement.scrollTop 的准确性问题,具有粘性和收缩效果
- persistent-volumes - 从不同组件访问 kubeflow 中的持久卷
- bitbucket-server - Butbucket-server 上的自定义翻新预设
- github - 我是否正确使用了 sra-toolkit 中的 fasterq-dump?
- python - 使用字符串和数字从列表中获取值
- java - Spring Boot 服务在空闲或服务过多请求后自动关闭
- javascript - 为什么我的汉堡菜单下拉菜单不能使用 javascript 工作?