css布局 夜游 2018-10-31 css 1.居中方案:12345678910<div class="wrapper"> <span>cool</span></div><style type="text/css"> .wrapper { display: table-cell; vertical-align: center; text-align: center; }</style> 或者flex布局: 1234567891011<div class="wrapper"> <span>cool</span></div><style type="text/css"> .wrapper { display: flex; flex-direction: row; justify-content: center; align-items: center; }</style> 绝对布局: 1234567891011121314<div class="wrapper"> <span>cool</span></div><style type="text/css"> .wrapper { position: relative; } .wrapper span { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }</style> 2.文字两端对齐:1text-align: justify;