html - Why is my css file for my ul class links keep on getting overwritten by user agent stylesheet?
问题描述
Can somebody help me please, as this is causing me sleepless nights. I've programmed a website with a navigation bar. The CSS code works fine when it is within the HTML code but when it is in a separate file the CSS code seems to only work on the li tags but not for the ul tags. Please see below for HTML & then the CSS.
ul.OPEN_menu {
display: block;
padding: 5px;
background-color: #c00;
border: 7px;
border-top-style: solid;
border-bottom-style: solid;
border-radius: 1em;
width: 10em;
list-style: none;
font: bold 20px Arial, sans-serif;
text-align: center;
text-transform: capitalize;
margin-left: auto;
margin-right: auto;
display: initial;
}
ul.closedMENU {
display: block;
padding: 5px;
background-color: #c00;
border: 7px;
border-top-style: solid;
border-bottom-style: solid;
border-radius: 1em;
width: 10em;
list-style: none;
font: bold 20px Arial, sans-serif;
text-align: center;
text-transform: capitalize;
height: 1em;
margin-left: auto;
margin-right: auto;
}
ul.closedsubmenu li {
padding: 5px;
background-color: yellow;
border: 7px;
border-top-style: solid;
border-bottom-style: solid;
border-radius: 1em;
width: 6.9em;
margin: 5px;
list-style: none;
margin-left: -45px;
visibility: hidden;
}
ul.OPEN_submenu li {
padding: 5px;
background-color: yellow;
border: 7px;
border-top-style: solid;
border-bottom-style: solid;
border-radius: 1em;
width: 6.9em;
height: 3em;
margin: 5px;
list-style: none;
margin-left: 13px;
visibility: visible;
font: bold 24px Arial, sans-serif;
text-align: center;
text-transform: capitalize;
}
ul.menu,
ul.menu ul {
display: none;
}
ul.menu li {
display: none;
}
ul.menu li ul {
display: none;
}
ul.menu a {
display: none;
}
ul.menu li ul li {
display: none;
}
ul.menu li ul li a {
display: none;
}
ul.menu li.submenu:hover {
display: none;
}
ul.menu li.submenu:hover ul {
display: none;
}
ul.menu li.submenu:hover ul li {
display: none;
}
ul.menu li.submenu:hover ul li:hover {
display: none;
}
<ul class="OPEN_menu OPEN_submenu" id="box1">
<div id="MENU_heading_HIDDEN">Menu</div>
<li id="MENU_heading_HIDDEN"><br>
<a href="../Game_Art_Work.html">Game Art Work</a></li>
<li id="MENU_heading_HIDDEN"><br>
<a href="../Games.html">Games</a></li>
<li id="MENU_heading_HIDDEN"><br>
<a href="../Games_D.html">Game D</a></li>
</ul>
解决方案
推荐阅读
- python - 来自透明的 Matplotlib Colourmap
- python-3.x - AttributeError:“NoneType”对象没有属性“media_player_new”
- reactjs - React - change another component
- xml - Xslt node exists for multiple elements
- node.js - koa/supertest - server.close is not a function
- pandas - Pandas: Applying '&' operator in df.query(), in mutiindex scenario
- sql-server - Connect app in Azure VM to SQL Server in shared environment
- azure-devops - 当有人编辑管道定义时,我如何获得通知?
- windows-mixed-reality - 如果文本转语音过多,我的 HoloLens 2 会关闭
- reactjs - 更改 React 材料表中的 addNewRow 图标位置