1-单行居中,多行居左。

2018-08-01  本文已影响15人  Vunbo

思维:

HTML

<div>
  <h2><p>单行居中,多行居左</p></h2>
  <h2><p>单行居中,多行居左,单行居中,多行居左单行居中,多行居左</p></h2>
</div>

CSS

div {
    margin: 100px auto;
    width: 400px;
    height: 400px;
    background: #ccc;
}
p {
    display: inline-block;
    text-align: left;
}
h2 {
    text-align: center;
}

效果

1.png

参考

有趣的CSS

上一篇 下一篇

猜你喜欢

热点阅读