文本 - 块不居中对齐

时间:2017-01-17 17:33:03

标签: html css

整个div仍然在左边,我尝试下面但没有运气



.captionhome {
  width: 600px;
  padding: 10px;
  border: 5px solid black;
  margin: 50px;
  font-weight: bold;
  font-size: 16px;
  text-align: center;
}

<div class="captionhome" style="text-align: center;">WARNING: This product contains nicotine. Nicotine is an addictive chemical.</div>
&#13;
&#13;
&#13;

enter image description here

1 个答案:

答案 0 :(得分:1)

您的captionhome有一个设定的宽度。将其更改为100%或添加

margin: 0 auto;