html - 居中左对齐文本

标签 html css

我想在黄色框 (txtbox) 中居中左对齐文本。 现在看起来像这样:

http://i.imgur.com/A1LaF0d.png

它希望它看起来像这样:

http://i.imgur.com/yHNjFqk.png

HTML:

       <div class="content container small">
                    <div class="txtbox">
                        <header style="text-align:left;">
                            <h2>I AIN'T</h2>
                            <h2>AN ARTIST.<h2>
                            <h2>I'M A</h2>
                            <h2>BEAST!</h2>
                        </header>
                    </div>
                <footer>
                    <a href="#one" class="button style2 down">More</a>
                </footer>
        </div>

CSS:

.container.small {
    /* width: (containers) * 0.75; */
    width: 900px;
}
.txtbox{
    width:800px;
    margin:0 auto;
    background-color:yellow;
    text-align:center;
}

最佳答案

.txtbox header h2{
    padding-left: 50px;
}

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

相关文章:

html - 这在 HTML5 中可行吗?

javascript - 类切换工作但规则不生效?

html - 切换侧边栏按钮在 Safari 浏览器中不可见

Javascript 验证 : compare string in dropdown list with other column in a table

html - 避免失去对选择的关注

javascript - 从 slider 中删除变体的尺寸图片 - Shopify

css - Bootstrap 按钮扩展容器

html - 在不改变视口(viewport)位置的情况下使用纯 CSS/HTML 弹出 div

java - Selenium (Java): how to locate browser validation message?

css - 哪个英文字母占据了最多的像素?