我有一個帶點導航和錨鏈接的頁面。 但我想錨鏈接指向該節中段,中心verticaly在頁面甚至與窗口的大小,就像這樣:帶一個頁面的點導航
大亮點:
較小的窗口:
此外,如何使突出顯示的鏈接點導航?像這樣的點導航:https://www.gumtreejobs.sg/當您在該部分上時,該點會變成綠色。
HTML:
<div class="nav">
<a href="#section01">01</a>
<a href="#section02">02</a>
<a href="#section03">03</a>
<a href="#section04">04</a>
</div>
<div class="content">
<div class="section" id="section01">Section 01</div>
<div class="section" id="section02">Section 02</div>
<div class="section" id="section03">Section 03</div>
<div class="section" id="section04">Section 04</div>
</div>
CSS:
body {
margin:0;
}
.nav {
position:fixed;
right:0;
}
.nav a {
display:block;
margin:10px;
height:30px;
width:30px;
border-radius:100%;
background:grey;
}
.nav a:hover {
background: orange;
}
.nav a.active{
background: red;
}
.section {
height:200px;
background:pink;
margin:100px;
}
你可以檢查你的樣張,看看CSS定義 – Garfield