Jump to content

Trouble aligning Google translate dropdown menu.


LeonLatex

Recommended Posts

As told in the heading, am I struggling with a dropdown menu that won't place where I want. I want it to move all over to the right, but for some reason, it won't.
The CSS can be a little messy since I have changed it forth and back in many attempts to make it work. Thanks for trying! 😊👍

Here are some of the HTML and CSS 

HTML
<body>
<div class="header_container">
<div class="logo_bar">
<div class="logo">
<div id="google_translate_element" style="margin-top:11px; margin-left: 32px;">
        <script type="text/javascript">
function googleTranslateElementInit() {
      new google.translate.TranslateElement({pageLanguage: 'no', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
    </div>
    </div>
    </div>
<div class="menu_bar" style="background-color: #ffffff;">
    <div class="menu">
    <a href='<?=$HOST?>index.php' class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Hjem</a>

   <a href='<?=$HOST?>index.php' class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Hjem</a>

   <a href='<?=$HOST?>index.php' class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Hjem</a>
</div></div></div>


CSS
div.logo_bar {
    background-color: #003333;
    /*box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;*/
    margin: auto;
    margin-top: 0px;
    width: 100%;
    height: 64px;
    padding: 0px;
    position: fixed;
}
div.logo {
    display: inline-flex;
    flex-direction: row;
    align-items: baseline;
    background-image: url("../images/logo_bg_original.png");
    width: 300px;
    height: 35px;
    margin-top:9px;
    margin-left: 10px;
    position: static;
}
div.translate {
    display:inline;
    flex-direction: row;
    align-items: baseline;
    width: 300px;
    height: 45px;
    margin-top:3px;
    margin-left: 10px;
    position: static;
}
div.menu_bar {
    font-size: 13px;
    /*font-weight: bold;*/
    background-color: #ffffff;
    box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
    margin: auto;
    margin-top: 54px;
    width: 100%;
    height: 50px;
    position: fixed;
}
div.menu {
    background-color: #ffffff;
    display: inline-flex;
    flex-direction: row;
    align-items: middle;
    margin-left: 0px;
    margin-top: 8px;
}

 

 

Link to comment
Share on other sites

Your tag nesting seems strange.  Why is your google translate box a child of your logo?  Your use of flex seems off as well.

Your logo a translate elements should probably be siblings, both children of the logo_bar element.  You could make logo_bar then either flex or grid to allocate most of the space to your logo div, and the minimum space to the translate element.

HTML:

<div class="header_container">
  <div class="logo_bar">
    <div class="logo"></div>
    <div id="google_translate_element">Google translate box</div>
  </div>
  <div class="menu_bar" style="background-color: #ffffff;">
    <div class="menu">
      <a href='<?=$HOST?>index.php' class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Hjem</a>
      <a href='<?=$HOST?>index.php' class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Hjem</a>
      <a href='<?=$HOST?>index.php' class='w3-bar-item w3-button w3-round-tiny w3-hover-white'>Hjem</a>
    </div>
  </div>
</div> 

CSS:

div.logo_bar {
    display: grid;
    grid-template-columns: auto max-content;
    background-color: #003333;
    margin: auto;
    margin-top: 0px;
    width: 100%;
    height: 64px;
    padding: 0px;
    position: fixed;
}
div.logo {
    width: 300px;
    height: 35px;
    margin-top:9px;
    margin-left: 10px;
}
div#google_translate_element {
    width: 300px;
    height: 45px;
    margin-top:3px;
    margin-left: 10px;
    color: white;
}
div.menu_bar {
    font-size: 13px;
    background-color: #ffffff;
    box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
    margin: auto;
    margin-top: 54px;
    width: 100%;
    height: 50px;
    position: fixed;
}
div.menu {
    background-color: #ffffff;
    display: inline-flex;
    flex-direction: row;
    align-items: middle;
    margin-left: 0px;
    margin-top: 8px;
} 

P.S. Remember to use Code blocks when posting your code.

 

Link to comment
Share on other sites

  • cyberRobot changed the title to Trouble aligning Google translate dropdown menu.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.