gpt4 book ai didi

javascript - 如何在
转载 作者:太空宇宙 更新时间:2023-11-04 10:42:21 25 4
gpt4 key购买 nike

我一直在尝试为自己建立一个个人网站,并且我已经构建了骨架。我的页面左侧有导航按钮和一个类为 .main 的内容区域。我想这样做,当单击按钮时,内容会加载到 .main div 中。我不知道如何解决这个问题,所以对解决方案的任何投入都会受到赞赏。以下是我目前拥有的 html 和 css 代码。

CSS:

  html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, caption {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: transparent;
}
html{
height: 100%;
width:100%;
}
body{
position: fixed;
background-color: #000000;
background-image: url(../images/background-lights1.jpg);
background-position: center;
background-size: contain;
background-repeat: no-repeat;
font-family: 'Asar', serif;
position: relative;
width: 100%;
overflow: hidden;
}
header{
position: fixed;
width: 100%;
height:75px;
}
aside{
position: fixed;
background-color: #000000;
width: 150px;
height: 550px;
border-bottom: 1px solid #FEB41C;

}

#buttons li{
position: relative;
list-style: none;
text-align: center;
background-color: #000000;
line-height: 60px;
padding: 38px 0 38px 0;
width: 150px;
border-top: 1px solid #3E474F;


}
#buttons li a{
text-decoration: none;
color: #FFFFFF;
padding: 3px;
transition: all 0.3s ease 0s;

}
#buttons li a:hover{
text-decoration: none;
border-bottom: 5px solid #FFFFFF;
padding: 20px;
color: #FEB41C;

}

#myPicture{
display: block;
height: 150px;
width: 150px;
border: 2px solid #FEB41C;
border-radius: 100%;
margin: 5px auto 5px auto;

}
.main{
background: linear-gradient(#849696, #FEFFFB);
height: 550px;
width: 100%;
border-top: 1px solid #FEB41C;
border-bottom: 1px solid #FEB41C;
overflow: hidden;

}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/limit-dne.css">
<link href='https://fonts.googleapis.com/css?family=Asar' rel='stylesheet' type='text/css'>
<script src="js/jquery.js"></script>
<link rel="icon" type="image/png" href="images/favicon-16x16.png" sizes="16x16" />
<title>The Limit Does Not Exist</title>
<header>
<img src="images/Dion.jpg" id="myPicture" alt="A picture of the site creator">
</header>
</head>
<body>
<div class="main">
<aside>
<ul id="buttons">
<li><a href="index.html">HOME</a></li>
<li><a href="portfolio.html">PORTFOLIO</a></li>
<li><a href="blog.html">BLOG</a></li>
<li><a href="contact.html">CONTACT</a></li>
</ul>
</aside>
</div>
<script>
</script>
</body>
</html>

CSS:

最佳答案

JavaScript:您可以使用一些简单的 jQuery 来做到这一点。例如:

var i = false;
$(document).ready(function() {
$('#home').click(function(){
if (i == false) {
$('#home_content').css("display","block");
i = true;
} else {
$('#home_content').css("display","none");
i = false;
};
});
});

HTML:

<div class="main">
<aside>
<ul id="buttons">
<li id="home"><a href="index.html">HOME</a></li>
<div id="home_content" style="display: none"></div>
<li><a href="portfolio.html">PORTFOLIO</a></li>
<li><a href="blog.html">BLOG</a></li>
<li><a href="contact.html">CONTACT</a></li>
</ul>
</aside>
</div>

关于javascript - 如何在 <div 中打开 html 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35690932/

25 4 0

Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com