html中使用mathjax數學公式

測試用例:
test.html:javascript

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="./test.css" />
<script type="text/x-mathjax-config">
      MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
    </script>
    <script type="text/javascript"
      src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
    </script>
</head>
<body>
<div id="header"><h1>備戰NOIP普及組專用網站</h1></div>
<div id="nav">
<a href="/chusai">初賽知識</a><br>
<a href="/fusai">複賽知識</a><br>
<br>
</div>
<div id="section">
<h1>公告</h1><br/>
<p>這個網站對持續更新到今年11月份。</p>
<p>但願能幫助你們在今年NOIP普及組取得好的成績。</p>
<p>When $a \ne 0$, there are two solutions to \(ax^2 + bx + c = 0\) and they are
        $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$</p>
</div>
<div id="footer">copyright zifeiy</div>
</body>
</html>

測試css文件:test.css:css

<style>
#header {
    background-color:black;
    color:white;
    text-align:center;
    padding:5px;
}
#nav {
    line-height:30px;
    background-color:#eeeeee;
    height:300px;
    width:80px;
    float:left;
    padding:5px;
}
#section {
    width:80%;
    float:left;
    padding:10px; 
    line-height: 5px;
}
#footer {
    background-color:black;
    color:white;
    clear:both;
    text-align:center;
    padding:5px;
}
</style>
相關文章
相關標籤/搜索