html - 如何左对齐,居中文本?

标签 html css twitter-bootstrap

<分区>


想改进这个问题吗? 通过 editing this post 添加细节并澄清问题.

关闭 7 年前

我有这个网站:

link

此时有 3 篇文章居中对齐。 位于中心但想左对齐,但是容器的中心...

代码 HTML:

<div class="col-lg-6 col-height">
                        <div class="text-box-right slideInRight animated">
                            <div class="title-home">LE BAGEL</div>

                            <div class="content-home"><p>est l’essence même de l’inspiration de la maison.<br>
Bagel House Café vous propose un pain unique, directement importé<br>
des Usa puis transformé dans nos cuisines.<br>
Ce pain à la forme si spéciale vous réserve bien des surprises…<br>
Choisissez-le nature, au sésame, au pavot, müesli, sans gluten ou<br>
encore laissez-vous tenter par le fameux “everything”.</p>
</div>
                        </div>
                    </div>

代码 CSS:

.col-height{
  height: 528px;
  display: table;
  text-align: center;
  font-size: 17pt;
}

.col-height div{
  width: 100%;
}

.title-home{
  font-size: 32pt;
  font-family: Myridad pro;
  color: #2a2b30;
}

你能帮我解决这个问题吗? 我希望我能够很好地解释他们想做什么

提前致谢!

最佳答案

将其添加到您的样式表中。一个简单的 text-align:left 就可以了。

要使内容位于容器中间,您需要为 p 设置宽度并设置 margin:auto

.content-home p
{
 text-align:left;
 width:70%;
 margin:auto;
}

结果是这样的

enter image description here

关于html - 如何左对齐,居中文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35308207/

上一篇:html - 增加 Bootstrap 中搜索栏的宽度

下一篇:javascript - 单击按钮添加/删除类

相关文章:

javascript - 某些 Google map 功能在 Blogger 中使用时未显示

javascript - 标题未完全隐藏或滚动到顶部时,粘性菜单快速跳转到顶部

css - 在与主要内容关联的导航栏中添加背景

css - Twitter Bootstrap Navbar 下拉样式

php - 在 EOT 中插入 php 代码

jquery - 将标题添加到现有图像 slider

html - 在多选选项中添加图标?

html - Bootstrap 切换的动画 'X' 图标

javascript - Apache 404 错误 - Drupal

javascript - 为段落动态分配类