开发者社区> 问答> 正文

css 一行文字时垂直居中

如何让它一行文字的时候垂直居中

    <style type="text/css">
        .ellipsis-2 {
            display: -webkit-box;
            overflow: hidden;
            text-overflow: ellipsis;
            word-wrap: break-word;
            white-space: normal !important;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            color: #fff;
        }
    </style>
    <div style="padding: 0 10px;height: 50px;background-color: #7092BE;width: 200px;">
        <p class="ellipsis-2">
            一行文字时垂直居中,两行文字时换行
        </p>
    </div>

展开
收起
杨冬芳 2016-06-12 17:46:44 2412 0
1 条回答
写回答
取消 提交回答
  • 行高等于高度就可以

    2019-07-17 19:34:48
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
零基础CSS入门教程 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载