为了账号安全,请及时绑定邮箱和手机立即绑定

老师,请问想让<pre></pre>标签内公式居中有什么好办法,我只能用空格解决的。

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>平方根</title>

</head>

<body>

<p>

<pre>              公式:x<sup>2</sup>+x=0 解<sub>:</sub> x<sub>1</sub>=0 x<sub>2</sub>=-1

</pre>

</p>

</body>

</html>


正在回答

5 回答

<head>
  <meta charset="utf-8">
  <title>平方根</title>
  <style type="text/css">
    pre {
     text-align:center;
    }
  </style>
</head>

<!--我还是个菜鸟-->

0 回复 有任何疑惑可以回复我~

<pre>这个标签我都忘了啥意思了   ._.

0 回复 有任何疑惑可以回复我~

通过设置“左右margin”值为“auto”来实现居中.

pre{

width:200px;

margin:20px auto;

}


0 回复 有任何疑惑可以回复我~

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>平方根</title>

<style tpye="text/css">

pre {text-align:center}

</style>

</head>

<body>

<p>

<pre>公式:x<sup>2</sup>+x=0 解<sub>:</sub> x<sub>1</sub>=0 x<sub>2</sub>=-1

</pre>


</body>

</html>


0 回复 有任何疑惑可以回复我~

你可以用其他的标签呀,比如div,然后把text-align属性设置为center就好了

1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

老师,请问想让<pre></pre>标签内公式居中有什么好办法,我只能用空格解决的。

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信