js 定位到某個錨點

2021-09-01 16:36:28 字數 447 閱讀 8542

html頁面內可以設定錨點,錨點定義

html**

<

aname

="firstanchor"

>

&nsbp;

a>

錨點使用

html**

<

ahref

="#firstanchor"

>

跳至第乙個錨點

a>

但對於js呢,在js中如何在完成乙個操作後跳至頁面的某個固定錨點呢

js中location.href可以跳轉至某個url;

跳至(定位到)某個固定錨點的辦法

1、location.href = "#firstanchor"; // firstanchor為錨點名稱

2、window.location.hash =firstanchor; // firstanchor為錨點名稱

js 定位到某個錨點

html頁面內可以設定錨點,錨點定義 html nsbp a 錨點使用 html 跳至第乙個錨點a 但對於js呢,在js中如何在完成乙個操作後跳至頁面的某個固定錨點呢 js中location.href可以跳轉至某個url 跳至 定位到 某個固定錨點的辦法 1 location.href firsta...

定位與錨點

只能用定位來實現層疊的效果 absolute預設為瀏覽器視窗 position static absolute relative fixed inherit 1.static 預設定位方式 2.absolute 絕對定位,將物件從文件流中完全脫離出來,使用left right top bottom進...

定位錨點透明

position定位屬性和屬性值 定位元素的層級屬性 包含塊的概念和應用 錨點連線的語法和應用場景 透明屬性的應用 擴充套件 marquee 滾動字幕 position定位屬性 告訴瀏覽器這是定位屬性 語法 position static absolute relative fixed 取值 1 s...