javascript - CSS 垂直对齐部分标签中的文本?

标签 javascript css node.js

我发布了一个我在做什么的例子

.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>

  

关于javascript - CSS 垂直对齐部分标签中的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53026779/

相关文章:

JavaScript 页内搜索和替换

JavaScript 错误

javascript - 尝试使用 npm 中的 'log' 包登录到 nodejs 上的文件

html - Angular 功能区 CSS

mysql - 使用 "Unknown Column"和 "limit"选项时,Sequelize 出现 "include"错误

javascript - 使用 Observable 排队 promise

html - 多个 CSS 类,带有一个元素

css - 在图像 html5 中定义对象

node.js - 谷歌云功能连接到 mongodb

node.js - 如何让 Forever 在启动时运行 Node.js 脚本?