- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的导航链接只会切换导航菜单本身。我让它在元素的开始和大部分时间都在工作,但是在构建一个更有活力的页脚的某个地方它刚刚停止工作并且似乎无法找到问题所在。我认为这可能与它的索引有关,或者可能是一个过低的问题
$(document).ready(function() {
$('#nav-mobile ul').hide();
$('#socialbtns').removeClass("socialbtns");
$('#ig').removeClass("fa fa-md fa-instagram");
$('#twitter').removeClass("fa fa-md fa-twitter");
$('#linkin').removeClass("fa fa-md fa-linkedin");
$('#trademark').removeClass("footer3");
$('#nav-mobile').click(function(e) {
e.preventDefault();
$('#nav-mobile ul').slideToggle();
});
resize();
$(window).resize(function() {
resize();
if(window.matchMedia("(max-width: 999px)").matches){
$(' <span> Instagram </span>').appendTo("#ig");
$$(' <span> Twitter </span>').appendTo("#twitter");
$('<span> LinkedIn </span>').appendTo("#linkin");
$('#trademark').addClass("footer3");
}
});
});
function resize(){
if (window.matchMedia("(min-width: 1000px)").matches) {
$('#nav-mobile').hide();
$('#socialbtns').addClass("socialbtns");
$('#ig').addClass("fa fa-md fa-instagram");
$('#twitter').addClass("fa fa-md fa-twitter");
$('#linkin').addClass("fa fa-md fa-linkedin");
$('span').remove();
$('#trademark').removeClass("footer3");
}
else {
$('#nav-mobile').show();
$('#socialbtns').removeClass("socialbtns");
$('#ig').removeClass("fa fa-md fa-instagram");
$('#twitter').removeClass("fa fa-md fa-twitter");
$('#linkin').removeClass("fa fa-md fa-linkedin");
$('#trademark').addClass("footer3");
}
};
/* Base Element Styles */
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Open Sans Condensed', sans-serif;
color: #000;
background-color: #F2F2F2;
display: flex;
flex-direction: column;
min-height: 100vh;
z-index: 1;
}
img {
height: 250px;
max-width: 90%;
padding-top: 30px;
display: block;
margin: 0 auto;
background-size: contain;
}
p {
font-size: 1em;
text-align: left;
padding: 15px;
}
a, a:hover, a:link {
color: inherit;
text-decoration: none;
opacity: .8;
}
li a {
color: #FFF;
text-align: center;
text-decoration: none;
}
/* Containers */
.container {
margin: 0 auto;
width: 90%;
text-align: center;
}
.img-container {
margin: 0 auto;
width: 90%;
}
.border {
padding: 5px 0;
border-top: 1px solid #FFF;
border-bottom: 1px solid #FFF;
}
.wrapper {
background-color: #121212;
padding-bottom: 50px;
}
/* Base Layout Styles */
.main-header {
background-image: url("../images/main.jpg");
background-size: cover;
background-repeat: no-repeat;
height: 280px;
width: 100%;
margin: 50px auto;
padding-top: 20px;
text-align: center;
}
.name {
font-size: 1.4em;
letter-spacing: 8px;
color: #FFF;
border-bottom: solid;
border-color: #000;
border-width: 2px;
display: inline-block;
}
.services {
font-size: 0.8em;
font-weight: 200;
color: #FFF;
}
#nav-mobile {
display: block;
padding: 10px;
font-size: 1em;
text-decoration: none;
text-align: center;
top:0;
}
#nav-mobile,
#nav-mobile ul,
#nav-mobile li {
position: relative;
}
#nav-mobile ul {
margin: 0;
padding: 0;
width: 100%;
text-align: center;
}
#nav-mobile ul li {
width: 100%;
display: block;
padding: 8px 0;
margin: 0;
color: #FFF;
text-align: center;
}
#nav-mobile a {
text-decoration: none;
color: #FFF;
outline: none;
}
.titles {
font-size: 1.1em;
font-weight: 700;
padding-top: 30px;
text-align: center;
}
.title-button {
background-color: #121212;
border: none;
color: #FFF;
padding: 10px 20px;
text-decoration: none;
font-size: 1em;
cursor: pointer;
display: inline;
}
.main-footer {
background-color: #121212;
color: #FFF;
font-size: .9em;
padding-top: 5px;
margin-top: 30px;
text-align: center;
}
.main-footer ul li {
list-style: none;
text-decoration: none;
width: 90%;
}
.footer3{
padding-top: 15px;
}
/* Social Media Icons */
.socialbtns li {
list-style: none outside none;
display: inline;
padding-left: 10px;
}
.socialbtns .fa {
width: 40px;
height: 28px;
color: #FFF;
border-radius: 20px;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
-o-border-radius: 20px;
transition: all ease 0.5s;
-moz-transition: all ease 0.5s;
-webkit-transition: all ease 0.5s;
-o-transition: all ease 0.5s;
}
.socialbtns .fa:hover {
transform: scale(1.2,1.2);
-moz-transform: scale(1.2,1.2);
-webkit-transform: scale(1.2,1.2);
-o-transform: scale(1.2,1.2);
transition: all ease 0.5s;
-moz-transition: all ease 0.5s;
-webkit-transition: all ease 0.5s;
-o-transition: all ease 0.5s;
}
/* Media Queries */
@media only screen and ( min-width: 670px){
img {
max-width: 80%;
height: auto;
}
p {
font-size: 1.4em;
}
.main-header {
height: 40vh;
}
.name {
font-size: 2.2em;
}
.services {
font-size: 1.2em;
}
#nav-mobile {
font-size: 1.4em;
}
}
@media screen and (min-width: 630px) and (orientation: landscape) {
.main-header {
max-height: 60%;
height: 100vh;
}
}
@media only screen and ( min-width: 1000px){
.container {
padding: 15px;
}
.wrapper {
height: 90%;
padding: 0;
}
.img-container{
min-width: 100%;
padding: 0;
position: relative;
}
.main-header {
margin: 0 auto;
width: 100%;
}
.name {
border-width: 4px;
}
.name,
.services {
font-size: 3.5em;
}
.title {
padding-top: 20px;
}
.section1 {
width: 40%;
float: left;
}
.section2 {
width: 40%;
float: right;
}
.main-footer {
font-size: 1.2em;
}
.main-footer ul {
width: 60%;
margin: 0 auto;
padding: 10px;
overflow: hidden;
white-space: no-wrap;
}
.main-footer ul li {
width: 100%;
}
.footer1,
.footer2 {
width: 45%;
padding-top: 10px;
overflow: hidden;
white-space: no-wrap;
}
.footer1 {
float: left;
display: block;
}
.footer2,
.footer3 {
text-align: center;
padding-left: 10px;
display: inline-block;
}
.footer2 li:nth-child(1) {
padding: 0;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="stylesheets/normalize.css">
<link rel="stylesheet" type="text/css" href="stylesheets/main.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet">
</head>
<body>
<!-- Menu Icon -->
<div class="wrapper">
<nav id="nav-mobile">
<a >Menu</a>
<ul>
<li><a href="bio.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="photos.html">Photography</a></li>
</ul>
</nav>
<!-- Home Page -->
<div class="img-container border">
<header class ="main-header">
<div class="title">
<div class="name"> Luis Rodriguez </div>
<div class="services"> Web Developer & Photographer </div>
</div>
</header>
</div>
</div>
<!-- Content Section -->
<div class="container">
<div class="section1">
<img src="images/pg1.jpg" alt="Photography">
<div class="titles"> Photography </div>
<p> In this era a photo does much more than merely remind us of a moment. It has by far become one of the most diverse forms of influence. We capture pictures of loved ones and bring tears of joy years later, while on the other hand busiensses rely on a picture to convey a "million words" to potential clients. Regardless of your story, the right photo should amaze you every time you see it.
</p>
<div class="title-button">
<a href="photos.html"> My Photos </a>
</div>
</div>
<div class="section2">
<img src="images/img1.jpg" alt="Code">
<div class="titles"> WebDev </div>
<p> When you ask someone to browse something online you really never know what they'll use anymore. You can have one person pull out their phone, another use a tablet, you've got someone on a desktop, and there may even be someone using their TV. Having a dynamic website is vital to ensuring that who ever is visiting your site can have a clean simple view to your page regardless of where they see it.
</p>
<div class="title-button">
<a href="code.html">My Code</a>
</div>
</div>
</div>
<footer class="main-footer">
<ul>
<div class="footer1">
<li><a href="bio.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
</div>
<div class="footer2">
<div class="socialbtns" id="socialbtns">
<li><a target="_blank" href="https://www.twitter.com/baesicmedia" id="twitter" class="fa fa-md fa-twitter"><span id="twitter-text">Twitter</span></a></li>
<li><a target="_blank" href="#" id="linkin" class="fa fa-md fa-linkedin"><span> LinkedIn</span></a></li>
<li><a target="_blank" href="https://www.instagram.com/baesicfrs/" id="ig" class="fa fa-md fa-instagram"><span> Instagram</span></a></li>
</div>
<div id="trademark" class="footer3">
<li>©2017 Baesic Media</li>
</div>
</div>
</ul>
</footer>
</body>
<script type="text/javascript" src="javascript/jquery-3.2.0.min.js"></script>
<script type="text/javascript" src="javascript/main.js"></script>
</html>
最佳答案
这段代码会帮助你,你的函数不会在 #nav-mobile ul > li >a
被点击时运行。
$('#nav-mobile').click(function(e) {
if(!$(e.target).is('#nav-mobile ul > li >a')){
e.preventDefault();
$('#nav-mobile ul').slideToggle();
}
});
$(document).ready(function() {
$('#nav-mobile ul').hide();
$('#socialbtns').removeClass("socialbtns");
$('#ig').removeClass("fa fa-md fa-instagram");
$('#twitter').removeClass("fa fa-md fa-twitter");
$('#linkin').removeClass("fa fa-md fa-linkedin");
$('#trademark').removeClass("footer3");
$('#nav-mobile').click(function(e) {
if(!$(e.target).is('#nav-mobile ul > li >a')){
e.preventDefault();
$('#nav-mobile ul').slideToggle();
}
});
resize();
$(window).resize(function() {
resize();
if(window.matchMedia("(max-width: 999px)").matches){
$(' <span> Instagram </span>').appendTo("#ig");
$(' <span> Twitter </span>').appendTo("#twitter");
$('<span> LinkedIn </span>').appendTo("#linkin");
$('#trademark').addClass("footer3");
}
});
});
function resize(){
if (window.matchMedia("(min-width: 1000px)").matches) {
$('#nav-mobile').hide();
$('#socialbtns').addClass("socialbtns");
$('#ig').addClass("fa fa-md fa-instagram");
$('#twitter').addClass("fa fa-md fa-twitter");
$('#linkin').addClass("fa fa-md fa-linkedin");
$('span').remove();
$('#trademark').removeClass("footer3");
}
else {
$('#nav-mobile').show();
$('#socialbtns').removeClass("socialbtns");
$('#ig').removeClass("fa fa-md fa-instagram");
$('#twitter').removeClass("fa fa-md fa-twitter");
$('#linkin').removeClass("fa fa-md fa-linkedin");
$('#trademark').addClass("footer3");
}
};
/* Base Element Styles */
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: 'Open Sans Condensed', sans-serif;
color: #000;
background-color: #F2F2F2;
display: flex;
flex-direction: column;
min-height: 100vh;
z-index: 1;
}
img {
height: 250px;
max-width: 90%;
padding-top: 30px;
display: block;
margin: 0 auto;
background-size: contain;
}
p {
font-size: 1em;
text-align: left;
padding: 15px;
}
a, a:hover, a:link {
color: inherit;
text-decoration: none;
opacity: .8;
}
li a {
color: #FFF;
text-align: center;
text-decoration: none;
}
/* Containers */
.container {
margin: 0 auto;
width: 90%;
text-align: center;
}
.img-container {
margin: 0 auto;
width: 90%;
}
.border {
padding: 5px 0;
border-top: 1px solid #FFF;
border-bottom: 1px solid #FFF;
}
.wrapper {
background-color: #121212;
padding-bottom: 50px;
}
/* Base Layout Styles */
.main-header {
background-image: url("../images/main.jpg");
background-size: cover;
background-repeat: no-repeat;
height: 280px;
width: 100%;
margin: 50px auto;
padding-top: 20px;
text-align: center;
}
.name {
font-size: 1.4em;
letter-spacing: 8px;
color: #FFF;
border-bottom: solid;
border-color: #000;
border-width: 2px;
display: inline-block;
}
.services {
font-size: 0.8em;
font-weight: 200;
color: #FFF;
}
#nav-mobile {
display: block;
padding: 10px;
font-size: 1em;
text-decoration: none;
text-align: center;
top:0;
}
#nav-mobile,
#nav-mobile ul,
#nav-mobile li {
position: relative;
}
#nav-mobile ul {
margin: 0;
padding: 0;
width: 100%;
text-align: center;
}
#nav-mobile ul li {
width: 100%;
display: block;
padding: 8px 0;
margin: 0;
color: #FFF;
text-align: center;
}
#nav-mobile a {
text-decoration: none;
color: #FFF;
outline: none;
}
.titles {
font-size: 1.1em;
font-weight: 700;
padding-top: 30px;
text-align: center;
}
.title-button {
background-color: #121212;
border: none;
color: #FFF;
padding: 10px 20px;
text-decoration: none;
font-size: 1em;
cursor: pointer;
display: inline;
}
.main-footer {
background-color: #121212;
color: #FFF;
font-size: .9em;
padding-top: 5px;
margin-top: 30px;
text-align: center;
}
.main-footer ul li {
list-style: none;
text-decoration: none;
width: 90%;
}
.footer3{
padding-top: 15px;
}
/* Social Media Icons */
.socialbtns li {
list-style: none outside none;
display: inline;
padding-left: 10px;
}
.socialbtns .fa {
width: 40px;
height: 28px;
color: #FFF;
border-radius: 20px;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
-o-border-radius: 20px;
transition: all ease 0.5s;
-moz-transition: all ease 0.5s;
-webkit-transition: all ease 0.5s;
-o-transition: all ease 0.5s;
}
.socialbtns .fa:hover {
transform: scale(1.2,1.2);
-moz-transform: scale(1.2,1.2);
-webkit-transform: scale(1.2,1.2);
-o-transform: scale(1.2,1.2);
transition: all ease 0.5s;
-moz-transition: all ease 0.5s;
-webkit-transition: all ease 0.5s;
-o-transition: all ease 0.5s;
}
/* Media Queries */
@media only screen and ( min-width: 670px){
img {
max-width: 80%;
height: auto;
}
p {
font-size: 1.4em;
}
.main-header {
height: 40vh;
}
.name {
font-size: 2.2em;
}
.services {
font-size: 1.2em;
}
#nav-mobile {
font-size: 1.4em;
}
}
@media screen and (min-width: 630px) and (orientation: landscape) {
.main-header {
max-height: 60%;
height: 100vh;
}
}
@media only screen and ( min-width: 1000px){
.container {
padding: 15px;
}
.wrapper {
height: 90%;
padding: 0;
}
.img-container{
min-width: 100%;
padding: 0;
position: relative;
}
.main-header {
margin: 0 auto;
width: 100%;
}
.name {
border-width: 4px;
}
.name,
.services {
font-size: 3.5em;
}
.title {
padding-top: 20px;
}
.section1 {
width: 40%;
float: left;
}
.section2 {
width: 40%;
float: right;
}
.main-footer {
font-size: 1.2em;
}
.main-footer ul {
width: 60%;
margin: 0 auto;
padding: 10px;
overflow: hidden;
white-space: no-wrap;
}
.main-footer ul li {
width: 100%;
}
.footer1,
.footer2 {
width: 45%;
padding-top: 10px;
overflow: hidden;
white-space: no-wrap;
}
.footer1 {
float: left;
display: block;
}
.footer2,
.footer3 {
text-align: center;
padding-left: 10px;
display: inline-block;
}
.footer2 li:nth-child(1) {
padding: 0;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="stylesheets/normalize.css">
<link rel="stylesheet" type="text/css" href="stylesheets/main.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet">
</head>
<body>
<!-- Menu Icon -->
<div class="wrapper">
<nav id="nav-mobile">
<a >Menu</a>
<ul>
<li><a href="bio.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
<li><a href="photos.html">Photography</a></li>
</ul>
</nav>
<!-- Home Page -->
<div class="img-container border">
<header class ="main-header">
<div class="title">
<div class="name"> Luis Rodriguez </div>
<div class="services"> Web Developer & Photographer </div>
</div>
</header>
</div>
</div>
<!-- Content Section -->
<div class="container">
<div class="section1">
<img src="images/pg1.jpg" alt="Photography">
<div class="titles"> Photography </div>
<p> In this era a photo does much more than merely remind us of a moment. It has by far become one of the most diverse forms of influence. We capture pictures of loved ones and bring tears of joy years later, while on the other hand busiensses rely on a picture to convey a "million words" to potential clients. Regardless of your story, the right photo should amaze you every time you see it.
</p>
<div class="title-button">
<a href="photos.html"> My Photos </a>
</div>
</div>
<div class="section2">
<img src="images/img1.jpg" alt="Code">
<div class="titles"> WebDev </div>
<p> When you ask someone to browse something online you really never know what they'll use anymore. You can have one person pull out their phone, another use a tablet, you've got someone on a desktop, and there may even be someone using their TV. Having a dynamic website is vital to ensuring that who ever is visiting your site can have a clean simple view to your page regardless of where they see it.
</p>
<div class="title-button">
<a href="code.html">My Code</a>
</div>
</div>
</div>
<footer class="main-footer">
<ul>
<div class="footer1">
<li><a href="bio.html">About</a></li>
<li><a href="contact.html">Contact</a></li>
</div>
<div class="footer2">
<div class="socialbtns" id="socialbtns">
<li><a target="_blank" href="https://www.twitter.com/baesicmedia" id="twitter" class="fa fa-md fa-twitter"><span id="twitter-text">Twitter</span></a></li>
<li><a target="_blank" href="#" id="linkin" class="fa fa-md fa-linkedin"><span> LinkedIn</span></a></li>
<li><a target="_blank" href="https://www.instagram.com/baesicfrs/" id="ig" class="fa fa-md fa-instagram"><span> Instagram</span></a></li>
</div>
<div id="trademark" class="footer3">
<li>©2017 Baesic Media</li>
</div>
</div>
</ul>
</footer>
</body>
<script type="text/javascript" src="javascript/jquery-3.2.0.min.js"></script>
<script type="text/javascript" src="javascript/main.js"></script>
</html>
关于javascript - 导航链接不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43650775/
我有一个网站,并且我使用 javascript sdk 添加了“点赞”按钮。 这是代码 (function(d, s, id) { var js, fjs = d.g
我知道 HTML 是逐行读取的。当您链接多个 css 文件(如规范化文件和样式表文件)时,由于 CSS 重要性特异性和源顺序,样式表文件应链接在规范化文件之后。看起来这不会影响链接的 JavaScri
我正在使用官方 Bootstrap site 提供的 CDN 链接在我的网络应用程序中使用面板进行测试 在彻底检查我的代码后,面板没有显示。 但是我在 SO 上看到了类似的帖子并且 CDN 链接不同
这里是编码初学者。我正在尝试为我的移动设备网站设置断点,以便我的网站适合小屏幕。我只是想检查如果我缩小视口(viewport)的宽度,背景颜色是否会改变,但没有发生任何变化。也许我只是对一个简单的错误
举一个我想要的例子,想象一下这个字符串: $text = 'lorem ipsum About us lorem ipsum'; 如果此字符串包含一个 href 以 / 开头的 anchor 链接,则
如何链接到 LaTeX 文档的另一部分或子部分?这种链接的常规范式是什么,像[链接名称]那样写,或者像网页超链接那样写? 最佳答案 链接到另一个部分需要您的部分进行一些额外的标记。要使用的命令是: \
我有一个订单表,其中包含订单号、客户 ID 和代理 ID。然后有一个带有 id 的客户表和一个带有 id 的代理表。 我需要获取所有具有来自代理 ID 'a03' 和代理 ID 'a05' 的订单的客
假设我有: dic = {"z":"zv", "a":"av"} ## Why doesn't the following return a sorted list of keys? keys = d
我在尝试链接到外部库时得到了一些奇怪的结果。如果我从命令行运行以下命令: gcc fftwTest.c -I../extlib/fftw-3.3.5-dll32 -L../extlib/fftw-3.
我认为我没有正确理解 jQuery 链接。我正在遍历一个数组并尝试将 div 元素添加到我的包装器 CSS 类中,每个 div 元素都有一个“click”类和自定义 css top 和 left 属性
HTML 使用超级链接与网络上的另一个文档相连。几乎可以在所有的网页中找到链接。点击链接可以从一张页面跳转到另一张页面。 HTML 超链接(链接) HTML使用标签 a 来设置超文本链接。 超链
这个问题在这里已经有了答案: How do I link to part of a page? (hash?) (7 个答案) Scroll Automatically to the Bottom
我想创建一个 Docker Swarm 集群,运行一个 Elasticsearch 实例、一个 MongoDB 实例和一个 grails 应用程序,每个都在单独的机器上。我正在使用 Docker Ma
我正在尝试将 CakePHP HTML Linker 用于以下代码 Add Cuisine 由于 span 标签需要在 a 标签内。我无法根据需要获得输出。关于如何完成它的任何建议? 最佳答案 禁用链
大家好, 我最近开发了一个应用程序,很快就会提交到 App Store。我想免费提交这个应用程序,并想知道我是否可以实现一个带有 PayPal 捐赠标志的按钮,上面基本上写着“捐赠用于开发”或与此相关
我想尝试在 dlang 中使用 libuv。我下载了这样的 dlang 绑定(bind): git clone git@github.com:tamediadigital/libuv.git 现在我接
我有一个节点(节点 a),各种其他节点(节点 b/c/d/e)与之引用。 我可以创建一个带有参数的 View 作为我正在查看的节点(节点 a),并获取引用该节点的节点列表。 基本上在节点 a 查看节点
我正在尝试建立一个常见问题页面,上面有目录,下面有答案。我想点击目录中的一个问题,并在同一页面上链接到相应的答案。我如何在 CakePHP 中使用 $this->Html->link() 执行此操作方
在 WooCommerce 3.0+ 中,我使用 js 创建了一些选项卡,每个选项卡中包含来自不同类别的产品。我已经设法修改了简单产品的添加到购物车链接,其中点击了 addtocart 按钮它进入下一
Delphi 2007/2009 奇怪的问题在这里: 根据设计时定义的组件属性,是否可以在链接中包含文件或保留文件? 示例:如果我将 SomeProperty 保留为真,则在编译时,单元 SomeUn
我是一名优秀的程序员,十分优秀!