2017-05-05 29 views
-1

我的網站的頭版我有此鏈接:http://temporal-16.d246.dinaserver.com/serveis#formulario如何加載頁面並通過url鏈接滾動到html元素?

還與http://temporal-16.d246.dinaserver.com/serveis/#formulario

然後在目標頁面我有這樣的嘗試:

<h2 style="text-align: center;" id="formulario"><a href="#formulario"></a>Sol·licita el teu servei aquí</h2> 

問題是,頁面加載但不是在正確的地方首先顯示h2元素。

我該如何解決這個問題?

+0

請改革你的問題...因爲它不清楚.. – Nomistake

回答

1

最多HTML 4目的地必須是

<a name="formulario">Sol·licita el teu servei aquí</a> 

(註名無#)

但隨着HTML 5,這是過時的和id

<h2 id="formulario">Sol·licita el teu servei aquí</h2> 
取代

參見MDN

此[name]屬性是定義頁面內可能的目標位置的錨所必需的。在HTML 4.01中,只要ID和名稱具有相同的值,就可以在<a>元素上同時使用。

+0

這一''name="formulario">'工作。謝謝。 – JPashs

相關問題