我正在使用 HTML 5 制作一个网站,我正在尝试为导航元素分配一定的高度。在我写的 CSS 文件中,元素的高度没有改变:
nav {
top: 0px;
right: 0px;
left: 0px;
position: fixed;
width: 100%
height: 5%;
background-color: white;
}
但是,当我进入 HTML 文件并再次执行时,它确实:
<style>
nav {
height: 5%;
}
</style>
有什么方法可以在仍然使用 CSS 文件的情况下解决这个问题?
最佳答案
你只是有一个语法错误:
nav{
top: 0px;
right: 0px;
left: 0px;
position: fixed;
width: 100%; <~~ you should put semi column at the end of each line
height: 5%;
background-color: white;
}
关于html - CSS 命令在 CSS 文件中不起作用,但在主 HTML 中起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47611983/