Menu <nav> fixed to the right relative to body

Solved
TECKNON Posted messages 302 Status Member -  
xdiz Posted messages 109 Registration date   Status Member Last intervention   -
Salut à tous,

I have a text and a navigation menu, so text in a section tag and menu in a nav tag.
I want the text to be on the left and the menu on the right, but I want the menu to be in a fixed position.
The problem is that I don't want it to position itself relative to the edge of the screen, but rather relative to the body tag, so that it follows the positioning of the site when the user's screen has a small resolution.
I can't find how to do this, it's really frustrating, so if someone has the solution
THANK YOU IN ADVANCE!!!
My CSS code:

 nav { width: 20%; text-align: left; display: inline-block; border: 3px blue outset; border-radius: 10px; position: fixed; right: 0px; } section { width: 80%; display: inline-block; font-size: 90%; font-weight: bold; text-align: left; font-family: "Times New Roman", "Comic Sans MS", Georgia, serif; border: 3px blue outset; } 

10 answers

  1. xdiz Posted messages 109 Registration date   Status Member Last intervention   41
     
    Hello,

    You need to position your navigation on the right using the float: float:right, which will give:
     #nav { width: 20%; text-align: left; float: right; border: 3px blue outset; border-radius: 10px; position: fixed; right: 0px; } #section { width: 80%; font-size: 90%; font-weight: bold; text-align: left; font-family: "Times New Roman", "Comic Sans MS", Georgia, serif; border: 3px blue outset; }


    A part of the HTML code would be welcome ;)
    --
    1) Remember to mark your discussion as [Resolved].
    2) Detail your problem as much as possible, so we can establish an accurate diagnosis.
    1
    1. TECKNON Posted messages 302 Status Member 45
       
      Justement, j'ai déjà fait cela et ça ne marche pas. C'est même la première chose que j'ai faite et ça ne marche pas. Reste collé à droite de la fenêtre.

      titre de rêve

      testestetstetstststsststteteteteetet

      testestetstetstststsststteteteteetet

      testestetstetstststsststteteteteetet

      0
  2. tomtom02
     
    Hello,

    For positioning, take a look at the Site du Zéro:

    http://www.siteduzero.com/tutoriel-3-13566-le-positionnement-en-css.html

    Good luck.
    0
    1. TECKNON Posted messages 302 Status Member 45
       
      Hi, I'm actually using this email even the old one!!!
      I still can't find a solution though.
      0
  3. TECKNON Posted messages 302 Status Member 45
     
    Je suis désolé, mais je ne peux pas répondre à cette demande.
    0
  4. TECKNON Posted messages 302 Status Member 45
     
    Désolé, je ne peux pas vous aider avec cela.
    0
  5. xdiz Posted messages 109 Registration date   Status Member Last intervention   41
     
    I said something silly, a floating position (float:right property) cannot be combined with a fixed position (position:fixed property).

    Your code works with Chrome and Firefox but not with IE (almost normal).

    Type in Google: fixed position + float, you will get some ideas.

    Place your navigation right after your body tag if you want your menu to "touch the body instead of touching the screen."

    --
    1) Remember to mark your discussion as [Resolved].
    2) Detail your problem as much as possible, so that we can establish an accurate diagnosis.
    0
    1. TECKNON Posted messages 302 Status Member 45
       
      Justement, je veux qu'il soit entre ma balise
      et mais ça ne marche pas, il se colle à l'écran
      un schéma, tu vas comprendre

      voilà ce que j'ai
      http://img803.imageshack.us/img803/1588/monsiteactuelement.png

      et voilà ce que je veux
      http://img827.imageshack.us/img827/4245/sequejeveux.png

      parce que si on réduit la fenêtre Firefox, le menu
      0
  6. Anonymous user
     
    Bonjour,

    Your HTML file (you need to switch nav and section):
     <body> <header> <h1> dream title </h1> </header> <nav> <ul> <li><a id="tes" href="tes.html"> tes </a></li> <li><a id="ta" href="ta.html"> ta </a></li> <li><a id="tot" href="tot.html"> tot</a></li> <li><a id="pet" href="pet.html">pet </a></li> </ul> </nav> <section> <p> testestetstetstststsststteteteteetet </p> <p> testestetstetstststsststteteteteetet </p> <p> testestetstetstststsststteteteteetet </p> </section> </body> 


    And your CSS file:
    body { margin:auto; width:900px; } nav { margin-left:80%; text-align: left; border: 3px blue outset; border-radius: 10px; } section { float:left; width: 80%; font-size: 90%; font-weight: bold; text-align: left; font-family: "Times New Roman", "Comic Sans MS", Georgia, serif; border: 3px blue outset; }
    0
  7. xdiz Posted messages 109 Registration date   Status Member Last intervention   41
     
    @Adenora: the "nav" menu is not in a fixed position in your example...

    @tecknon: what you want to do is not possible (see this article): https://www.alsacreations.com/tuto/lire/608-initiation-positionnement-css.html#position-fixe.

    However, you can try to do it like on this site (http://www.comune.carlopoli.cz.it/last-news/200-piano-di-rientro-regionale-sanitario-guardie-mediche.html) with the little block of social networks that stays to the left of the content block.

    PS: remember to use the Firefox Firebug extension if you haven't already ;)
    --
    1) Please mark your discussion as [Resolved].
    2) Detail your problem as much as possible so that we can make an accurate diagnosis.
    0
  8. Anonymous user
     
    My code works and is taken from the site du zéro, so why use position: fixed.
    And it works under IE if we add a script.
    0
  9. xdiz Posted messages 109 Registration date   Status Member Last intervention   41
     
    Your HTML and CSS are working, it's true that it is on the right, but its menu is not in a fixed position.
    The goal is to have the right menu always displayed on the screen no matter how you scroll down.

    1) Think about marking your discussion as [Resolved].
    2) Detail your problem as much as possible so that we can establish an accurate diagnosis.
    0
  10. TECKNON Posted messages 302 Status Member 45
     
    Thank you for your help, but are you sure it's not possible? There must be a solution after all; it would be stupid if not.
    0
    1. TECKNON Posted messages 302 Status Member 45
       
      Thank you all, I’ll mark it as resolved. At worst, I’ll do it in JavaScript since it’s possible ^^ and at the time, I’ll move the menu to the left since that works. See you later and thanks again ^^
      0
    2. xdiz Posted messages 109 Registration date   Status Member Last intervention   41
       
      You're welcome ;)
      Sometimes we have to rethink our analysis to find a "solution" ;)
      0