html - CSS - Button:focus 不允许我点击链接
问题描述
我正在尝试创建一个网站,当我单击“菜单”时,它会向我显示带有链接的导航栏。当我尝试单击其中一个链接时,它们突然消失了。我知道这是因为焦点按钮不再被定位,但我怎样才能让它让我点击那里?
一些图片可以让您更好地理解它->
关闭菜单-
打开菜单
一些用于样式的CSS可能丢失了,但这就是给我带来问题的那个
nav {display: none;
height: 13em;
padding-top: 1em;
border-bottom-left-radius: 1em;
border-bottom-right-radius: 1em;
}
.navbutton {
text-align: center;
text-decoration: none;
width: 30%;
font-family: sans-serif;
color: #1b5e20;
padding-top: 0.2em;
font-weight: bold;
margin-left:35%;
margin-bottom: 0.5em;
border-radius: 1em;
font-size: 100%;
background-color: white;
}
button {height: 3em;
width: 100%;
background-color: #1b5e20;
color: white;
transition: 0.3s;
display: block;
border-style: none;}
.menu {font-family: sans-serif;
text-align: center;
margin-left: 0 auto;
margin-right: 0 auto;
background-color: white;
border-radius: 1em;
color:white;
background-color: #4c8c4a;
padding-left: 1em;
padding-right: 1em;
font-size: 1.6em;
}
.close {
display:inline;
text-align: center;
text-decoration: none;
font-family: sans-serif;
color: white;
padding: 0.3em;
font-weight: bold;
margin-left:48%;
margin-top: 5%;
border-radius: 100em;
background-color: darkred;
cursor: pointer;
}
.close:hover, .close:active {display: none;}
<html lang="de" dir="ltr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Mediterrane Pflanzen Alongi - Photogallery</title>
<link rel="stylesheet" type="text/css" href="design.css" />
<style>
button:active+nav, button:focus+nav {display: block;}
button:active+nav, button:focus+nav {display: block;}
</style>
</head>
<body>
<button>
<a class="menu">Menu</a>
</button>
<nav class="navbar">
<a class="navbutton" href="mediterrane pflanzen home.html">Home</a>
<a class="navbutton" href="mediterrane%20pflanzen%20photogallery.html">Galerie</a>
<a class="navbutton" href="mediterrane pflanzen kontakt.html">Kontakt</a>
<a class="navbutton" href="mediterrane%20pflanzen%20uber%20uns.html">Über uns</a>
<a class="navbutton" href="mediterrane%20pflanzen%20impressum.html">Impressum</a>
<a class="close">X</a>
</nav>
解决方案
推荐阅读
- http - 是否可以在浏览器中调用解析?
- google-classroom - 调用课堂 PHP API 方法时出错:courses.courseWork.list
- c# - sftp文件上传C#
- pyspark - Spark shell 打开时出现异常:无法从 URL [文件:log4j 属性] 读取配置文件
- wordpress - 如何阻止重力表单提交保存到本地数据库?
- java - 如何使用 Selenium/Java 在前钩子中动态获取正确的页面类?
- sqlite - 在内存中使用 xUnit/EFCore/sqlite 时测试之间的数据溢出
- ansible - 使用 if 条件将 True 或 False 分配给 Ansible 中的gather_facts 不起作用
- spartacus-storefront - 更改特定组件的响应媒体的媒体类型
- c# - 如何从 HttpRequestMessage.Properties 迁移到 HttpRequestMessage.Options