ここでかなり大きな質問です。基本的には、index.html を読み込むときに中央の見出しを持つサイトを作成していますが、jquery を使用してヘッダーを変更し、ユーザーがリンクをクリックしたときにトランジションでヘッダーをページの上部に移動したいと考えています。ヘッダーが立ち上がるとコンテンツがフェードします。したがって、変更してパネルを変更するdisplay: hidden;
誰かが解決策を提供できれば、それは大歓迎です[私はjsにかなり慣れていないため、以前にjqueryを行ったことがありませんが、jqueryが使用するのに最適なライブラリのようです]
<!DOCTYPE html>
<html>
<head>
<title>Chris Calcroft • Arbitrator</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/stuff.js"></script>
</head>
<body>
<div class='header'>
<img src='img/header.jpg' alt='header'>
<ul class='headerNav'>
<li id='about' onclick='pageChange(id);'>about</li>
<li id='projects' onclick='pageChange(id);'>projects</li>
<li id='contact' onclick='pageChange(id);'>contact</li>
</ul>
<div>
</body>
</html>
JS:
$(function pageChanger(id) {
$("id").click(function() {
$(".header").toggleClass(".header-transition");
});
});
CSS:
@font-face {
font-family: avant;
src: url('font/avant.ttf');
}
html {
background-color: black;
color: white;
font-family: avant;
}
.header {
position: fixed;
top: 50%;
left: 50%;
margin-top: -175px;
margin-left: -450px;
-webkit-transition: top 2s ease,
left 2s ease,
margin-left 2s ease,
margin-top 2s ease,
position 2s ease;
}
.header-transition {
top: 0;
left: 0;
margin-top: 0;
margin-left: auto;
margin-right: auto;
position: static;
display: block;
}
li {
text-decoration: none;
display: inline;
padding: .2% 1.3%;
}
li:hover {
color: gray;
}
これは私がこれまでに持っているものです。クラスを切り替えるために正しいIDをjqueryに渡そうとすると、壁にぶつかりました。
みんなありがとう :)