我使用外部腳本和外部樣式創建了一個簡單的html頁面。 在其中使用< li>元素顯示菜單列表。通過外部.js文件內聯顯示列表元素
我的頁面中的問題是,列表元素以塊方式垂直顯示,儘管它們應該以內聯方式顯示。 我無法找到糾正的錯誤,所以在這裏我附上了所有相關的代碼。如果你找到它,請幫助我知道錯誤。 謝謝。
<!DOCTYPE HTML>
<html>
<head>
<title>
WEB pAGE
</title>
<link rel="stylesheet" type="text/css" href="mystyle.css">
<div class="div1">
<h1 align="center">Hello</h1>
</div>
<script src="myscript.js"></script>
</head>
<body onload = "myfunction()">
<br><br><br><br><br><br>
<div class="div3"><br></div>
<div class="mmm">abcde</div>
</body>
</html>
myscript.js
function myfunction() {
var x = document.getElementsByClassName("mmm");
x[0].innerHTML = x[0].innerHTML = '<ul id="menu" align="center"><li id= "m1"><a href="abc.html" id="tn" > Abc</a></li><br> <li id= "m1"> <a href="def.html" id="tn">DEF</a></li><br><li id= "m1"><a href="ghi" id="tn" >GHI</a></li><br><li id= "m1"><a href="jkl.html" id="tn"> JKL</a></li></ul> ';
}
mystyle.css
h1 {
font-family:Comic Sans MS;
}
.div1 {
position:fixed;
height:110px;
width:1350px;
background-color:Teal;
color:White;
margin:0px;
padding:0px;
}
.mmm{ position:fixed;
top:115px;
left:419px;
background-color:#69A005;
color:White;
height:50px;
width:1000px;
}
.div3{ position:fixed;
top:115px;
background-color:#69A005;
color:White;
height:50px;
width:430px;
}
ul#menu{ color:white;
margin:5px;
padding:0px;
}
li#m1 {
display:inline;
margin:10px;
padding:10px;
color:White;
}
a#tn { display:inline;
width:90px;
background-color:#000000;
padding:5px;
}