关于css text-align:center

时间:2016-09-23 08:13:09

标签: html css text-align

我写了一个类似下面页面的页面,只是复制相同的css样式代码,但text-align发生了一些事情。 http://mp.weixin.qq.com/s?__biz=MjM5ODQwMjA4MA==&mid=2649293603&idx=1&sn=57f38200555dcba76d6358594416c089&scene=1&srcid=0922hwo0hW1YFpZ5km00qu8f#rd

红线的文字应该是中心。对齐的地方:左边是什么?我没有在代码中写这个。这是我写的html文件的源代码。

enter image description here

这里的文字样式代码是:

<section style="box-sizing: border-box; background-color: rgb(255, 255, 255);"><section style=" box-sizing: border-box; "><section style=" margin-top: 10px; margin-bottom: 10px; box-sizing: border-box; "><section style="box-sizing: border-box; text-align: center;"><section style="display: inline-block;vertical-align: top;padding: 8px 5px 5px 3px;width: 50%;box-sizing: border-box;border-right: 1px solid #66CCC5;"><section style="box-sizing: border-box;"><section  style="margin-top: 0.5em; margin-bottom: 0.5em; box-sizing: border-box;"><section style="box-sizing: border-box;width: 4em;height: 4em;display: inline-block;vertical-align: bottom;border-radius: 100%;background-image: url(&quot;http://mmbiz.qpic.cn/mmbiz/xpE6LLZTjLjZbC3icL0gxysDXhDQB9iaUPkFkZTfWxshdqfjuibeO84QQRovVcvYY4yhRLQPHusytjcicic7iav0GNvg/0?wx_fmt=jpeg&quot;);background-size: cover;background-position: 50% 50%;background-repeat: no-repeat;" class=""><br></section><p><span style="font-size: 14px;color: rgb(102, 204, 197);line-height: 1.6;">阿禅 Jason Ng</span></p></section></section></section><section style="display: inline-block;vertical-align: top;padding: 6px;width: 50%;box-sizing: border-box;"><section style="box-sizing: border-box; border: 1px solid rgb(102, 204, 197); padding: 8px 5px; width: 120px; color: rgb(102, 204, 197); border-radius: 2px; margin: auto; line-height: 20px; font-size: 14px;"><p>读完本文<br>大约需要</p><section style="font-size: 30px;color:#666;line-height: 38px;">6</section>分钟</section></section></section></section></section></section>< 

源代码:view-source:http://7rf31y.com1.z0.glb.clouddn.com/index.html 你可以复制并粘贴一个本地html文件,然后用chrome打开它。

1 个答案:

答案 0 :(得分:1)

span没有对齐样式默认值,但p确实如此,因此span继承p样式,包括左对齐。 首先,我没有看到任何理由将这个跨度放入p,你可以简单地使用P,但它不相关...... 您必须在容器和容器上添加一个类&gt; paragraf将文本置于中心位置如下:

&#13;
&#13;
ResultViewController
&#13;
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let secondVC = segue.destination as! ResultViewController
    secondVC.transitioningDelegate = self
    secondVC.modalPresentationStyle = .custom
}
&#13;
&#13;
&#13;

它必须在不使用儿童声明的情况下工作,但因为我不知道你的风格,我让你按原样防止错误。请不要在html标签中设置样式 - .-

干杯!

相关问题