html - 如何在现有网站/导航上创建下拉菜单?
问题描述
我是一个 17 岁的男孩,最近刚开始使用 html 和 css,我一直在制作一个网站,我正在尝试在我现有的网站上添加一个下拉菜单,但我正在努力做到这一点,我想要一个下降我的照片选项卡上的下拉菜单,这样我就可以在“关于”选项卡中添加一些图片和一张,我尝试过不起作用,任何帮助将不胜感激和欢迎。提前致谢
*
{
margin: 0;
padding: 0;
}
header
{
background-image:linear-gradient(rgba(0,0,0,0.5),rgba(0,0,0,0.5)),url(1493004618106.jpg);
height: 100vh;
background-size: cover;
background-position: center;
}
.main-nav
{
float: right;
list-style: none;
margin-top: 30px;
}
.main-nav li
{
display: inline-block;
}
.main-nav li a
{
color: white;
text-decoration: none;
padding; 5px 20px;
font-family: "Roboto", sans-serif;
font-size: 15px;
}
.main-nav li.active a
{
border: 1px solid white;
}
.main-nav li a:hover
{
border: 1px solid white;
}
.logo img
{
width: 100px;
height: auto;
float: left;
}
body
{
font-family: monospace;
}
.row
{
max-width: 1200px
margin: auto;
}
.hero
{
position: absolute;
width: 1000px;
margin-left: 200px;
margin-top: 0px;
margin-right: 50px;
}
h1
{
color: white;
text-transform: uppercase;
font-size: 70px;
text-align: center;
margin-top: 275px;
}
.button
{
margin-top: 30px;
margin-left: 330px;
}
.btn
{
border : 1px solid white;
padding: 10px 30px;
color: white;
text-decoration: none;
margin-right: 5px;
font-size: 13px;
text-transform: uppercase
}
.btn-one
{
background-color: darkblue;
font-family: "Roboto", sans-serif;
}
.btn-two
{
font-family: "Roboto", sans-serif
}
.btn-two:hover
{
background-color: darkblue
}
index.html
<html>
<head>
<title>Bryan's Holidays</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<header>
<div class="row">
<div class="logo">
<img src="fr.png">
</div>
<ul class="main-nav">
<li class="active"><a href=""> HOME</a></li>
<li><a href=""> ABOUT</a></li>
<li><a href=""> PHOTOS</a></li>
<li><a href=""> CONTACT</a></li>
</ul>
</div>
<div class="hero">
<h1>WELCOME!</h1>
<div class="button">
<a href="" class="btn btn-one"> Watch video</a>
<a href="" class="btn btn-two"> Explore more</a>
</div>
</div>
</header>
</body>
</html>
解决方案
这对你有帮助吗?
https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_dropdown_hover
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<body>
<div class="w3-container">
<h2>Dropdown Button</h2>
<p>Move the mouse over the button to open the dropdown content.</p>
<div class="w3-dropdown-hover">
<button class="w3-button w3-black">Hover Over Me!</button>
<div class="w3-dropdown-content w3-bar-block w3-border">
<a href="#" class="w3-bar-item w3-button">Link 1</a>
<a href="#" class="w3-bar-item w3-button">Link 2</a>
<a href="#" class="w3-bar-item w3-button">Link 3</a>
</div>
</div>
</div>
</body>
</html>
推荐阅读
- lua - 为什么在这个 Lua 5.1 __gc 解决方法中将 userdata 对象添加到表中?
- c++11 - 使用 RegNotifyChangeKeyValue 进行注册表监控
- java - 获取用户在休眠环境中所做的所有更改
- firebase - 从 Google App Engine 标准环境使用 Cloud Firestore 需要什么
- react-native - onChange 文本未更新其状态
- c# - 预制件不会为不同的玩家同步
- c# - 异步等待方法调用外部资源或返回本地字符串
- c# - Azure 函数 SignalR | 协商功能 | 失败并显示 500 错误代码
- python - Message.content.split() Discord.PY
- javascript - 如何在滚动时让一个项目 div 移动而其他项目不移动?