html - 作为 Main Nav 的一部分的 Spacing 下拉选项的复杂性
问题描述
我正在为一门课程做最后的项目,在这个学期即将结束时,教授几乎没有帮助我。问题:我设法让侧面的主导航正常工作并在工作下生成一个下拉菜单。下拉菜单也正确旋转,但是选项彼此堆叠。我已经没有想法尝试让它们正确间隔。任何帮助表示赞赏。谢谢你。
#rotate-text {
text-align: center;
width: 25px;
transform: rotate(270deg);
}
.navbar{
overflow: hidden;
background-color: aliceblue;
font-family: cursive;
}
/* Style the links inside the navigation bar */
.topnav a {
transform-origin: top left;
transform: rotate(-90deg) translateX(-100%);
font-family: 'Bevan', cursive;
float:left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-weight: bolder;
font-size: 20px;
}
.dropdown{
float: center;
overflow: hidden;
}
.dropdown .dropbtn {
transform-origin: top left;
transform: rotate(-90deg) translateX(-100%);
font-family: 'Bevan', cursive;
float:left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-weight: bolder;
font-size: 20px;
border: solid;
outline: none;
background-color: inherit;
}
.dropdown-content {
display: none;
position: absolute;
min-width: 160px;
z-index: 1;
left: 70px;
}
.dropdown-content a {
float: none;
color: #f2f2f2;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the color of links on hover */
.topnav a:hover {
color:aqua
}
.topnav a.active
{
border-color: cadetblue;
}
/*-90 rotate
.topnav a: rotate {
transform: rotate(-90deg);
}
<html>
<head>
<link href='finale.css' rel='stylesheet'/>
<style>
body{
background-image: url(BGGradient.png);
background-repeat:no-repeat;
}
#title{
text-align: center;
font-family: cursive;
font-size: 36pt;
font-weight: bolder;
color: #f2f2f2;
}
#base{
border: solid;
}
</style>
</head>
<body>
<div id="title">
Zurion Oasis
</div>
<div>
<table height=100% width=100%>
<tr>
<td>
<table height=100%>
<tr>
<td class="topnav" style="height:100px">
<a href="#contact">CONTACT</a>
</td>
</tr>
<tr>
<td class="topnav" style="height:100px">
<a href="#about">ABOUT</a>
</td>
</tr>
<tr>
<td class="topnav" style="height:100px">
<div class="dropdown" id="work">
<button class="dropbtn">WORK
</button>
<div class="dropdown-content">
<a href="#">Photography</a>
<a href="#">Digital</a>
<a href="#">Physical Medium</a>
</div>
</div>
</td>
</tr>
<tr>
<td class="topnav" style="height:100px">
<a class="active" href="#home">HOME</a>
</td>
</tr>
</table>
</td>
<td>
<div id="base">
REST OF PAGE GOES HERE
</div>
</td>
<tr>
</table>
</div>
</body>
</html>
解决方案
您需要在代码中更改这两个 css 以消除堆叠问题。
<html>
<head>
<link href='finale.css' rel='stylesheet'/>
<style>
body{
background-image: url(BGGradient.png);
background-repeat:no-repeat;
}
#title{
text-align: center;
font-family: cursive;
font-size: 36pt;
font-weight: bolder;
color: #f2f2f2;
}
#base{
border: solid;
}
</style>
</head>
<body>
<div id="title">
Zurion Oasis
</div>
<div>
<table height=100% width=100%>
<tr>
<td>
<table height=100%>
<tr>
<td class="topnav" style="height:100px">
<a href="#contact">CONTACT</a>
</td>
</tr>
<tr>
<td class="topnav" style="height:100px">
<a href="#about">ABOUT</a>
</td>
</tr>
<tr>
<td class="topnavv" style="height:100px" style="">
<div class="dropdown" id="work">
<span class="dropbtn">WORK</span>
<div class="dropdown-content">
<a href="#"><p>Photography</p></a>
<a href="#"><p>Digital</p></a>
<a href="#"><p>Physical Medium</p></a>
</div>
</div>
</td>
</tr>
<tr>
<td class="topnav" style="height:100px">
<a class="active" href="#home">HOME</a>
</td>
</tr>
</table>
</td>
<td>
<div id="base">
REST OF PAGE GOES HERE
</div>
</td>
<tr>
</table>
</div>
</body>
</html>
和CSS:
/* Style the links inside the navigation bar */
.topnav a {
transform-origin: top left;
transform: rotate(-90deg) translateX(-100%);
font-family: 'Bevan', cursive;
float:left;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-weight: bolder;
font-size: 20px;
}
.topnavv{
font-family:'Bevan',cursive;
color: #f2f2f2;
text-decoration: none;
font-weight: bolder;
font-size:20px;
text-decoration: none;
vertical-align: inherit;
}
.topnavv a{
transform-origin: top left;
font-family:'Bevan',cursive;
color: #f2f2f2;
text-decoration: none;
font-weight: bolder;
font-size:20px;}
.dropdown {
position: relative;
display: inline-block;
transform: rotate(-90deg) translateX(-50%);}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 1;
}
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the color of links on hover */
.topnav a:hover {
color:aqua
}
.topnav a.active
{
border-color: cadetblue;
}
/*-90 rotate
.topnav a: rotate {
transform: rotate(-90deg);
}
推荐阅读
- azure-devops - 在 Azure Dev 中格式化水平线
- android - 反应本机移动应用程序:获取最大调用堆栈大小超出错误
- node.js - express-http-context npm 模块不适用于快速发布请求
- reactjs - 在 react-redux 应用程序中将子组件与商店连接的问题
- javascript - 如何将按钮链接到其他页面中的选项卡?
- asp.net-web-api - Web API 和视图在同一个控制器中
- google-apps-script - 以编程方式创建触发器时如何使用版本化部署?
- objective-c - 将 MKPointAnnotation 保存到 Firestore
- python - 如何根据传递给其 __init__ 方法的字符串值命名类中的变量?
- java - 如何将一个对象投射到另一个对象