LeonLatex Posted March 7, 2023 Share Posted March 7, 2023 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; } Quote Link to comment https://forums.phpfreaks.com/topic/315983-trouble-aligning-google-translate-dropdown-menu/ Share on other sites More sharing options...
kicken Posted March 7, 2023 Share Posted March 7, 2023 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. Quote Link to comment https://forums.phpfreaks.com/topic/315983-trouble-aligning-google-translate-dropdown-menu/#findComment-1606326 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.