CSSの位置の役割:スティッキー;
スティッキーなナビゲーションバーを作成するには、次の位置を使用します。財産。次のコードを実行して、スティッキーなナビゲーションバーを作成してみてください。
例
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
position: sticky;
overflow: hidden;
top: 0;
width: 100%;
}
li {
float: left;
border-right: 1px solid white;
}
li a {
display: block;
padding: 8px;
background-color: orange;
}
li:last-child {
border-right: none;
}
div {
padding:5px;
margin-top:5px;
background-color:white;
height:1000px;
}
</style>
</head>
<body>
<ul>
<li><a href = "#home">Home</a></li>
<li><a href = "#news">News</a></li>
<li><a href = "#contact">Contact</a></li>
<li><a href = "#about">About</a></li>
</ul>
<div>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
<p>Adding demo text to check fixed menu.</p>
</div>
</body>
</html> -
CSSの位置:静的;
位置:静的; プロパティは、要素の位置を静的に設定します。これがデフォルトです。 例 top、bottom、left、およびrightプロパティは、静的に配置された要素には影響しません。次のコードを実行して、CSSの position:static;を実装してみてください。 プロパティ <!DOCTYPE html> <html> <head> <style> div.static { &nbs
-
CSSの位置:修正済み。
位置:固定; プロパティを使用すると、ビューポートを基準にして要素を配置できます。次のコードを実行して、CSSの位置を実装してみてください。fixed; 例 <!DOCTYPE html> <html> <head> <style> div{ position: fixed; &nbs