html - 如何以我的风格居中文本?

标签 html css

我试图将我的文本“EXAMPLE”居中。我的 span 标签中有文本对齐中心,但它没有居中。我只想要“示例”中心而不是其他文本。

查看我的 jsfiddle:http://jsfiddle.net/huskydawgs/dx5fe6x5/

HTML

<p class="textbox">
<span style="text-align:center; color:#2251a4; font-weight:bold;letter-spacing: 10px;">EXAMPLE</span><br><br> The powers of the Company shall be exercised by or under the authority of, and the business and affairs of the Company shall be managed under the direction of, one or more managers. The Manager(s) shall be: Jane Doe, John Doe and Yogi Berra.</p>

CSS

.textbox {
padding: 8px 12px;
color: #555555;
background-color: #F1F1F1;
border: #e2e3e4 2px solid;
}

最佳答案

添加display:block;到 span 样式:

.textbox {
    padding: 8px 12px;
color: #555555;
background-color: #F1F1F1;
border: #e2e3e4 2px solid;
}
.title{
    text-align:center;
    color:#2251a4; 
    font-weight:bold;
    letter-spacing: 10px;
    display:block;
        
}
<p class="textbox">
    <span class="title">EXAMPLE</span>
  he powers of the Company shall be exercised by or under the authority of, and the business and affairs of the Company shall be managed under the direction of, one or more managers. The Manager(s) shall be: Jane Doe, John Doe and Yogi Berra.
</p>

我强烈建议您不要使用内联样式,而只使用 <br>是应该使用它们的地方,不是结构!
JSFiddle Demo

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

相关文章:

html - 如何防止 outlook 破坏 div 大小? (通讯)

javascript - 避免克隆 HTMLTemplate 来检索 innerHTML?

html - CSS三 Angular 形的一个边缘上的边框阴影

html - 如何修复每个列表项之间的这些差距?

javascript - 如何在不提交的情况下获取将提交的所有表单值

javascript - 将 Canvas 用于游戏的真正好处是什么?

html - 如何使div响应

css - 调整浏览器窗口大小时,导航不包含在父 div 中

jquery - WP 主题中的背景图像 slider - 父元素不透明度隐藏内容

javascript - 如何更改站点主体元素的背景以与幻灯片放映相对应?