我剛開始學習網頁設計,想創建一個側邊欄。我在 w3school 上查了一下,很喜歡這個設計,但無法理解一些運算式,例如 .overlay 類之后的 a、javascript:void(0)、@media screen 和 (max-height: 450px) 等。有人可以嗎教我每個人都做什么?謝謝您的幫助。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: 'Lato', sans-serif;
}
.overlay {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0, 0.9);
overflow-x: hidden;
transition: 0.5s;
}
.overlay-content {
position: relative;
top: 25%;
width: 100%;
text-align: center;
margin-top: 30px;
}
.overlay a {
padding: 8px;
text-decoration: none;
font-size: 36px;
color: #818181;
display: block;
transition: 0.3s;
}
.overlay a:hover, .overlay a:focus {
color: #f1f1f1;
}
.overlay .closebtn {
position: absolute;
top: 20px;
right: 45px;
font-size: 60px;
}
@media screen and (max-height: 450px) {
.overlay a {font-size: 20px}
.overlay .closebtn {
font-size: 40px;
top: 15px;
right: 35px;
}
}
</style>
</head>
<body>
<div id="myNav" class="overlay">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<div class="overlay-content">
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Clients</a>
<a href="#">Contact</a>
</div>
</div>
<h2>Fullscreen Overlay Nav Example</h2>
<p>Click on the element below to open the fullscreen overlay navigation menu.</p>
<p>In this example, the navigation menu will slide in, from left to right:</p>
<span style="font-size:30px;cursor:pointer" onclick="openNav()">☰ open</span>
<script>
function openNav() {
document.getElementById("myNav").style.width = "100%";
}
function closeNav() {
document.getElementById("myNav").style.width = "0%";
}
</script>
</body>
</html>
uj5u.com熱心網友回復:
好的,我會一個接一個地回答你的問題
- 在
<a>后元件.overlay-content元件是在邊欄中的鏈接。 javascript:void(0)向瀏覽器指定鏈接不應重定向到任何頁面或重新加載當前頁面。這是因為該鏈接用于特定功能(打開和關閉側邊欄)。然而,這不是語意。<button>如果要執行單擊操作,請使用元素。@media screen and (max-height: 450px)是一個斷點,包含滿足條件的規則(從 0px 高度到 450px 高度)。因此,這里的所有規則僅適用于螢屏高度小于等于 450 像素的情況。
uj5u.com熱心網友回復:
@media screen and (max-height: 450px) 僅在瀏覽器視窗為450 px時應用指定條件
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/395229.html
標籤:javascript html 查询 css 侧边栏
上一篇:請求被其他資料覆寫
