- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我一直在努力让我的导航栏响应,我一直在使用 W3Schools 作为指南来尝试实现响应式导航栏但未能成功,我希望出现一个图标,该图标将在访问我的时显示移动设备上的作品集,但我无法完成此任务,下面我将链接我使用的 w3schools 页面、我的代码和它在我的网站上的外观示例。
https://www.w3schools.com/howto/howto_js_topnav_responsive.asp
Example of how it look on a phone
function myFunction() {
var x = document.getElementById("mynav-area");
if (x.className === "nav-area") {
x.className += " responsive";
} else {
x.className = "nav-area";
}
}
body {
margin: 0;
padding: 0;
font-family: impact;
margin: 0;
background: #0F2027;
background: linear-gradient(to bottom, #0F2027, #080e10);
max-width: 100%;
max-height: 100%;
}
.fix {
clear: both;
overflow: hidden;
}
header {
overflow: hidden;
height: 100vh;
}
.nav-area {
z-index: 1;
float: right;
height: 70px;
position: relative;
text-align: center;
width: 100%;
top: 1%;
}
.menu-area {
float: right;
top: 15%;
list-style: none;
margin: 20px;
}
.menu-area li {
display: inline-block;
margin: 0px;
}
.menu-area li a {
text-decoration: none;
color: #fff;
padding: 0px 20px;
letter-spacing: 2px;
font-family: sans-serif;
}
.menu-area li.active a {
color: #FF00BD;
}
.menu-area li a:hover {
color: #FF00BD;
}
.banner-text {
position: absolute;
text-align: center;
top: 50%;
left: 50%;
font-family: sans-serif;
transform: translate(-50%, -50%);
}
.banner-text h2 {
color: #fff;
font-size: 80px;
margin: 0;
}
.banner-text h3 {
color: #fff;
font-size: 30px;
margin: 0;
}
.banner-text-hi {
position: absolute;
color: #fff;
font-size: 80px;
width: 60%;
text-align: center;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-family: sans-serif;
}
.banner-text-hi h2 {
color: #fff;
font-size: 80px;
margin: 0;
}
.banner-text-hi h3 {
color: #FF00BD;
font-size: 30px;
margin: 0;
}
.banner-text-name {
z-index: 1;
float: left;
position: absolute;
color: #fff;
width: 60%;
text-align: center;
top: 3.5%;
right: 55%;
font-family: sans-serif;
text-decoration: none;
}
.banner-text-name h2 {
color: #fff;
font-size: 20px;
margin: 0;
font-family: sans-serif;
text-decoration: none;
}
.banner-text h2 span {
color: #FF00BD;
}
canvas {
display: block;
height: 100vh;
width: 100vh;
}
.snow {
pointer-events: none;
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
max-width: 100%;
max-height: 100%;
}
.split {
color: white;
font-family: sans-serif;
height: 100%;
width: 33.33%;
position: fixed;
top: 0;
overflow-x: hidden;
padding-top: 0px;
}
.left {
left: 0;
background: #0F2027;
background: linear-gradient(to bottom, #0F2027, #080e10);
}
.left h2 {
color: aliceblue;
font-family: sans-serif;
}
.right h2 {
color: aliceblue;
font-family: sans-serif;
}
.center {
left: 33%;
right: 33%;
background: #0F2027;
background: linear-gradient(to bottom, #0F2027, #080e10);
}
.right {
right: 0;
background: #0F2027;
background: linear-gradient(to bottom, #0F2027, #080e10);
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.centered img {
width: 150px;
}
a {
text-decoration: none;
}
.class1,
.class2,
.class3 {
width: 33.33%;
float: left;
height: 100px;
color: #fff;
font-family: sans-serif;
}
p {
padding-top: 25px;
text-align: center;
}
@import "bourbon";
$col-primary: #00c7ec;
$corner-radius: 5px;
.button {
z-index: 0;
text-decoration: none;
text-transform: uppercase;
font-family: 'Exo 2', sans-serif;
font-weight: 300;
font-size: 30px;
display: inline-block;
position: relative;
text-align: center;
color: $col-primary;
border: 1px solid $col-primary;
border-radius: $corner-radius;
line-height: 3em;
padding-left: 5em;
padding-right: 5em;
box-shadow: 0 0 0 0 transparent;
@include transition(all 0.2s ease-in);
&:hover {
color: white;
box-shadow: 0 0 30px 0 transparentize($col-primary, 0.5);
background-color: $col-primary;
@include transition(all 0.2s ease-out);
&:before {
@include animation(shine 0.5s 0s linear);
}
}
&:active {
box-shadow: 0 0 0 0 transparent;
@include transition(box-shadow 0.2s ease-in);
}
&:before {
content: '';
display: block;
width: 0px;
height: 86%;
position: absolute;
top: 7%;
left: 0%;
opacity: 0;
background: white;
box-shadow: 0 0 15px 3px white;
@include transform(skewX(-20deg));
}
}
@include keyframes(shine) {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
@import "compass/css3";
$width : 220px;
$height: 70px;
$border: 4px;
$violet: #6559ae;
$orange: #ff7159;
$deg : 120deg;
$size: 400%;
$dur : 3s;
@mixin clip-frame($width, $height, $border) {
-webkit-clip-path: polygon(0% 100%, $border 100%, $border $border, $width - $border $border, $width - $border $height - $border, $border $height - $border, $border 100%, 100% 100%, 100% 0%, 0% 0%);
}
.position {
margin-left: auto;
margin-right: auto;
text-align: center;
margin-top: 15%;
}
#workarea {
position: absolute;
width: 100%;
height: 100%;
background-color: #1e1a3e;
font-family: Raleway;
}
#personal {
color: white;
text-decoration: none;
position: absolute;
bottom: 15px;
right: 2%;
}
/* start code for the actual button: */
/*
Spot is the span on the inside of the href that
fills the parent and makes the hover and link work
for the entire div
*/
.spot {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
/*
This is the outer svg wrapper that the SVG itself will
fill. Multiple svg-wrapper classes can be put side by side.
*/
.svg-wrapper {
margin-top: 0;
position: relative;
width: 150px;
/*make sure to use same height/width as in the html*/
height: 40px;
display: inline-block;
border-radius: 3px;
margin-left: 5px;
margin-right: 5px
}
/*
This is where we define the fill, color, thickness,
and stroke pattern of the SVG when there is no hover.
The dasharray and offset together define the line position
under the words. Here's also where the transition speed is set.
*/
#shape {
stroke-width: 6px;
fill: transparent;
stroke: #FF00BD;
stroke-dasharray: 85 400;
stroke-dashoffset: -220;
transition: 1s all ease;
}
/*
Pushing the text up into the SVG. Without this the
text would be below the div's.
*/
#text {
margin-top: -35px;
text-align: center;
}
#text a {
color: white;
text-decoration: none;
font-weight: 100;
font-size: 1.1em;
}
/*
Changing the shape on hover. I change the color of the stroke,
make it thinner, then set it to again wrap around the entire parent element.
*/
.svg-wrapper:hover #shape {
stroke-dasharray: 50 0;
stroke-width: 3px;
stroke-dashoffset: 0;
stroke: #FF00BD;
}
@media screen and (max-width: 600px) {
.nav-area a:not(:first-child) {
display: none;
}
.topnav a.icon {
float: right;
display: block;
}
}
/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */
@media screen and (max-width: 600px) {
.nav-area.responsive {
position: relative;
}
.nav-area.responsive a.icon {
position: absolute;
right: 0;
top: 0;
}
.nav-area.responsive a {
float: none;
display: block;
text-align: left;
}
}
.nav-area .icon {
display: none;
}
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>Joe's Portfolio</title>
</head>
<body>
<!-- Navigation Bar -->
<header class="fix">
<div class="nav-area">
<ul class="menu-area">
<li class="active"><a href="index.html">Home</a></li>
<li><a href="work.html">Coursework</a></li>
<li><a href="future.html">Future Aspirations</a></li>
<li><a href="about.html">About Me</a></li>
<li><a href="cvpage.html.html">CV</a></li>
<li><a href="contact.html">Contact</a></li>
<a href="javascript:void(0);" class="icon" onclick="myFunction()">
<i class="fa fa-bars"></i>
</a>
</ul>
<!-- Navigation Bar End -->
[1]: /image/v8ErC.png
最佳答案
我已经用你的 css 和 html 更新了响应式菜单,检查一下,希望这对你有帮助。
function myFunction() {
var x = document.getElementById("mynav-area");
if (x.className === "menu-area") {
x.className += " responsive";
} else {
x.className = "menu-area";
}
}
body {
margin: 0;
padding: 0;
font-family: impact;
margin: 0;
background: #0F2027;
background: linear-gradient(to bottom, #0F2027, #080e10);
max-width: 100%;
max-height: 100%;
}
.fix {
clear: both;
overflow: hidden;
}
header {
overflow: hidden;
height: 100vh;
}
.nav-area {
z-index: 1;
float: right;
height: auto;
position: relative;
text-align: center;
width: 100%;
}
.menu-area {
list-style: none;
margin: 0;
padding: 0;
text-align: left;
}
.menu-area li {
display: inline-block;
margin: 0px;
}
.menu-area li a, .nav-area a {
text-decoration: none;
color: #fff;
padding: 20px;
letter-spacing: 2px;
font-family: sans-serif;
display: inline-block;
}
.menu-area li.active a{
color: #FF00BD;
}
.menu-area li a:hover {
color: #FF00BD;
}
.banner-text {
position: absolute;
text-align: center;
top: 50%;
left: 50%;
font-family: sans-serif;
transform: translate(-50%, -50%);
}
.banner-text h2 {
color: #fff;
font-size: 80px;
margin: 0;
}
.banner-text h3 {
color: #fff;
font-size: 30px;
margin: 0;
}
.banner-text-hi {
position: absolute;
color: #fff;
font-size: 80px;
width: 60%;
text-align: center;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-family: sans-serif;
}
.banner-text-hi h2 {
color: #fff;
font-size: 80px;
margin: 0;
}
.banner-text-hi h3 {
color: #FF00BD;
font-size: 30px;
margin: 0;
}
.banner-text-name {
z-index: 1;
float: left;
position: absolute;
color: #fff;
width: 60%;
text-align: center;
top: 3.5%;
right: 55%;
font-family: sans-serif;
text-decoration: none;
}
.banner-text-name h2 {
color: #fff;
font-size: 20px;
margin: 0;
font-family: sans-serif;
text-decoration: none;
}
.banner-text h2 span {
color: #FF00BD;
}
canvas {
display: block;
height: 100vh;
width: 100vh;
}
.snow {
pointer-events: none;
position:fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
max-width: 100%;
max-height: 100%;
}
.split {
color: white;
font-family: sans-serif;
height: 100%;
width: 33.33%;
position: fixed;
top: 0;
overflow-x: hidden;
padding-top: 0px;
}
.left {
left: 0;
background: #0F2027;
background: linear-gradient(to bottom, #0F2027, #080e10);
}
.left h2 {
color: aliceblue;
font-family: sans-serif;
}
.right h2 {
color: aliceblue;
font-family: sans-serif;
}
.center {
left:33%;
right:33%;
background: #0F2027;
background: linear-gradient(to bottom, #0F2027, #080e10);
}
.right {
right: 0;
background: #0F2027;
background: linear-gradient(to bottom, #0F2027, #080e10);
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.centered img {
width: 150px;
}
a {
text-decoration: none;
}
.class1,
.class2,
.class3 {
width: 33.33%;
float: left;
height: 100px;
color: #fff;
font-family: sans-serif;
}
p {
padding-top: 25px;
text-align: center;
}
@import "bourbon";
$col-primary: #00c7ec;
$corner-radius: 5px;
.button {
z-index: 0;
text-decoration: none;
text-transform: uppercase;
font-family: 'Exo 2', sans-serif;
font-weight: 300;
font-size: 30px;
display: inline-block;
position: relative;
text-align: center;
color: $col-primary;
border: 1px solid $col-primary;
border-radius: $corner-radius;
line-height: 3em;
padding-left: 5em;
padding-right: 5em;
box-shadow: 0 0 0 0 transparent;
@include transition(all 0.2s ease-in);
&:hover {
color: white;
box-shadow: 0 0 30px 0 transparentize($col-primary, 0.5);
background-color: $col-primary;
@include transition(all 0.2s ease-out);
&:before {
@include animation(shine 0.5s 0s linear);
}
}
&:active {
box-shadow: 0 0 0 0 transparent;
@include transition(box-shadow 0.2s ease-in);
}
&:before {
content: '';
display: block;
width: 0px;
height: 86%;
position: absolute;
top: 7%;
left: 0%;
opacity: 0;
background: white;
box-shadow: 0 0 15px 3px white;
@include transform(skewX(-20deg));
}
}
@include keyframes(shine) {
from {
opacity: 0;
left: 0%;
}
50% {
opacity: 1;
}
to {
opacity: 0;
left: 100%;
}
}
@import "compass/css3";
$width: 220px;
$height: 70px;
$border: 4px;
$violet: #6559ae;
$orange: #ff7159;
$deg: 120deg;
$size: 400%;
$dur: 3s;
@mixin clip-frame($width, $height, $border) {
-webkit-clip-path: polygon(0% 100%, $border 100%, $border $border, $width - $border $border, $width - $border $height - $border, $border $height - $border, $border 100%, 100% 100%, 100% 0%, 0% 0%);
}
.position {
margin-left: auto;
margin-right: auto;
text-align: center;
margin-top: 15%;
}
#workarea {
position: absolute;
width: 100%;
height: 100%;
background-color: #1e1a3e;
font-family: Raleway;
}
#personal {
color:white;
text-decoration:none;
position:absolute;
bottom:15px;
right:2%;
}
/* start code for the actual button: */
/*
Spot is the span on the inside of the href that
fills the parent and makes the hover and link work
for the entire div
*/
.spot {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
/*
This is the outer svg wrapper that the SVG itself will
fill. Multiple svg-wrapper classes can be put side by side.
*/
.svg-wrapper {
margin-top: 0;
position: relative;
width: 150px;
/*make sure to use same height/width as in the html*/
height: 40px;
display: inline-block;
border-radius: 3px;
margin-left: 5px;
margin-right: 5px
}
/*
This is where we define the fill, color, thickness,
and stroke pattern of the SVG when there is no hover.
The dasharray and offset together define the line position
under the words. Here's also where the transition speed is set.
*/
#shape {
stroke-width: 6px;
fill: transparent;
stroke: #FF00BD;
stroke-dasharray: 85 400;
stroke-dashoffset: -220;
transition: 1s all ease;
}
/*
Pushing the text up into the SVG. Without this the
text would be below the div's.
*/
#text {
margin-top: -35px;
text-align: center;
}
#text a {
color: white;
text-decoration: none;
font-weight: 100;
font-size: 1.1em;
}
.topnav a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
/*
Changing the shape on hover. I change the color of the stroke,
make it thinner, then set it to again wrap around the entire parent element.
*/
.svg-wrapper:hover #shape {
stroke-dasharray: 50 0;
stroke-width: 3px;
stroke-dashoffset: 0;
stroke: #FF00BD;
}
.nav-area .icon {
display: none;
}
@media screen and (max-width: 991px) {
.nav-area ul li:not(:first-child) {
display: none;
background: #212020;
}
ul.menu-area.responsive li:first-child {
background: #212020;
}
.nav-area a.icon {
float: right;
display: block;
position: absolute;
right: 0;
top: 0;
}
.nav-area.responsive {position: relative;}
ul.menu-area.responsive li {
display: block;
background: #3c3a3a;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Navigation Bar -->
<header class="fix">
<div class="nav-area">
<ul class="menu-area" id="mynav-area">
<li class="active"><a href="index.html">Home</a></li>
<li><a href="work.html">Coursework</a></li>
<li><a href="future.html">Future Aspirations</a></li>
<li><a href="about.html">About Me</a></li>
<li><a href="cvpage.html.html">CV</a></li>
<li><a href="contact.html">Contact</a></li>
<a href="javascript:void(0);" class="icon" onclick="myFunction()">
<i class="fa fa-bars"></i>
</a>
</ul>
</div>
</header>
<!-- Navigation Bar End -->
关于javascript - 响应式导航栏(移动设备问题),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54346650/
我正在尝试检查 Entry 中是否存在重复项,并使用内联消息提醒用户该数字存在。 $(document).ready(function(){ $("#con1").blur(function(
我有一个基于类的 View 。我在引导模式上使用 Ajax。为了避免页面刷新,我想使用此类基于 View 返回 JSON 响应而不是 HTTP 响应,但我只看到了如何为基于函数的 View 返回 JS
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
我有一个大型内部企业基于 Web 的应用程序在 IIS6 上运行 ASP.NET 3.5,生成 401 个“未经授权”响应,然后是 200 个“Ok”响应(如 Fiddler 所述)。我知道为什么会发
感谢您研究我的问题。 我有一个node/express服务器,配置了一个server.js文件,它调用urls.js,而urls.js又调用 Controller 来处理http请求,所有这些都配置相
当我使用以下命令时,我得到正确的 JSON 响应: $ curl --data "regno=&dob=&mobile=" https://vitacademics-rel.herokuapp.co
我有一个非常简单的 RESTful 服务,它通过 POST 接收一些表单数据,其目的是在云存储(Amazon S3、Azure Blob 存储等)中简单地保留文本主体(具有唯一 ID)作为一个文件..
UDP 不发送任何 ack,但它会发送任何响应吗? 我已经设置了客户端服务器UDP程序。如果我让客户端向不存在的服务器发送数据,那么客户端会收到任何响应吗? 我的假设是; 客户端 --> 广播服务器地
我有一个电梯项目,其中 有一个扩展 RestHelper 的类,看起来像这样 serve{ "api" / "mystuff" prefix { case a
我们正在寻求覆盖 Kong 错误响应结构并编写自定义消息(即用我们的自定义消息替换“超出 API 速率限制”、“无效的身份验证凭据”等)。 我们要找的错误响应结构(代码是自定义的内部错误代码,与HTT
我正在尝试监听 EKEventStoreChangedNotification 以检查当我的应用程序处于后台时日历是否已更改。 我在 View Controller 的 initWithNibMeth
我了解 javascript,并且正在学习 ASP.NET C# 我想要做什么(完成的是javascript): document.getElementById('divID-1'
是否可以过滤所有 har 对象并仅获取 POST 请求/响应?也许在初始化 BrowserMobProxyServer 期间是这样做的方法?我需要将 har 对象保存到文件中并上传到 har 查看器。
我正在尝试向 Oauth 的 API 发送响应。遗憾的是,Symfony2 文档在解释 $response->headers->set(...); 的所有不同部分方面做得很差。 这是我的 OauthC
我正在尝试测试用例来模拟 api 调用,并使用 python 响应来模拟 api 调用。 下面是我的模拟, with responses.RequestsMock() as rsps: url
在尝试在 Haskell 中进行一些领域驱动设计时,我发现自己遇到了这个问题: data FetchAccessories = FetchAccessories data AccessoriesRes
我正在与 ANT+ USB 棒连接,并用项目 react 器替换我自己天真的“MessageBus”,因为它看起来非常合适。 USB接口(interface)本质上是异步的(单独的输入/输出管道),我
我正在将项目迁移到AFNetworking 2.0。使用AFNetworking 1.0时,我编写了代码来记录控制台中的每个请求/响应。这是代码: -(AFHTTPRequestOperation *
我有以下代码段。 ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){
我有问题......我在 php 中有一个监听器脚本可以执行以下操作: if ($count != 1) {echo 'no';} else { echo "yes";} 因此它会回显"is"或“
我是一名优秀的程序员,十分优秀!