Link to a div on another page does not work

Asked

Viewed 1,124 times

1

I have this code:

<div id="text"><p>A Intertráfego está disponível a ser alcançada a qualquer momento.
Saiba <a href="pedir_cotacao.html#map">onde estamos</a> e <a
href="pedir_cotacao.html#otherQuestion"> os nossos contactos </a></p></div>

The problem is that the link to the map does not work, changes to the correct page but not to the div I want, and the other link (ask quotation#otherQuestion) works perfectly, I have tried even an invisible div on top of the map and put the link to this div and tb does not give. Any tips? Obgado

  • 1

    You could post your html code from this page request quote.html#map ?

  • I think that’s the answer to your question. &#xD; &#xD; http://stackoverflow.com/questions/7314990/link-a-div-to-a-particular-section-on-a-different-page-in-html

  • 1

    Is there enough space under the div (or enough div height) for it to be at the top of the screen? For example, imagine that the div "map" is the bottom of the page and is 200px high, if there is no space underneath for the scroll to occur and get to the top of the screen, it will only be 200px from the bottom of the screen and so it doesn’t seem to work, but it actually works. I wonder if I understood?

  • I understand, but is this the case? http://www.iwanttobesanta.com/order_quotation.html The link is being made on the home page (index)

  • http://www.iwanttobesanta.com/order_quotation.html#otherQuestion and http://www.iwanttobesanta.com/order_quotation.html#map work, what’s the problem?

  • The links are on the index. And if we click on the link to go to the map ("...where we are..") although going to the correct page does not go to the map div

  • I understand, I believe the problem lies in the fact that you’re using absolute Ivs. I noticed that the "#otherQuestion" also does not work because it is not positioning properly, although it seems. This will have to be done with Jquery: http://stackoverflow.com/questions/3972082/problem-with-html-anchor-in-absolute-div-300px-from-the-top

  • Obgado, but because it says that they are not positioned properly?

  • Because when opening with the anchor "#otherQuestion", you should position the div at the top of the screen since there is a scroll for this, but it does not contain, it is in the middle of the page, so it is not working properly.

Show 4 more comments

1 answer

2

What prevents being positioned correctly is the CSS property position: relative. Place the 2 elements as position: static, or without such a definition, because static is the standard.

#otherQuestion {
    /*position: relative; -> Remova */
    float: left;
    height: 450px;
    width: 100%;
    border-top: 2px solid #1a1a1a;
}
#map {
    /*position: fixed; - Remova */
    width: 100%;
    height: 450px;
    /*bottom: 0; -> tb desnecessário */
    border: 0;
}

HTML:

<div id="map" style="background-color: rgb(229, 227, 223); overflow: hidden; -webkit-transform: translateZ(0px);">
  • I think it would not solve since the structure of the page depends on a relative position, it would have to change more things.

  • Why depends? I changed here dynamically to Static by Devtoolbar and changed nothing.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.