我使用外部脚本和外部样式创建了一个简单的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;
}