这个元素/覆盖死区内的中心文本?

时间:2013-08-21 10:01:45

标签: css ruby-on-rails centering

我不确定这里的问题是什么,但是在这个元素内部左侧有一些死区,它不响应我做的任何事情。我想将文本居中在元素中(并且居中,只有左边有一些似乎没有被考虑的空白空间)。这是一张图片:

enter image description here

您可以看到左侧的填充比右侧的填充大得多。我尝试手动设置padding-left,但这不起作用。

这是页面中的元素(我正在使用rails):

<div class="holder round clear eval_body">
  ...
  <div class="box center">
    Before continuing to the next student, 
    <br />please take a moment to review the scores for <%= @student.name %>.
    <br />  
    <span class='strong'>
      Once you have submitted them, they cannot be changed!
    </span>
  </div>
  ...
</div>

box元素

.box {
    position: relative;
    bottom: 3px;
    left: 10em;
    width: 50%;
    height: 8%;
    background: #B05C37;
    border: 3px solid #902D00;
    color: #fff;
}

3 个答案:

答案 0 :(得分:0)

将您的css课程更改为.box center而不是.box

答案 1 :(得分:0)

感谢您的建议(特别是techvineet)。得到它的工作:

.box {
    position: absolute;
    bottom: 3.5%;
    right: 7%;
    margin: 5px;
    padding: 20px;
    width: 50%;
    background: #B05C37;
    border: 3px solid #902D00;
    color: #fff;
}

答案 2 :(得分:0)

添加

text-align: center;

到CSS中的.box。