Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 440989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:55:39+00:00 2026-05-12T20:55:39+00:00

I’m trying to a language switching system in this website. The idea is to

  • 0

I’m trying to a language switching system in this website. The idea is to have a SPAN which upon hover displays a dropdown box (UL based) that contains a list of available languages. Here’s a snapshot of the effect I’m trying to achieve.

alt text http://img337.imageshack.us/img337/3474/dropboxfinal.png

The dropdown box is actually an unordered list that is hidden by default. Upon hovering on the span, I’m making the UL visible. Here’s the HTML and the CSS.

HTML

<span id="langswitch">Language↓
    <ul id="langlist">
        <li class="en">
            <a title="Current language: English" href="http://domain/en">
                <img width="16" height="13" alt="English Language" src="flag-en.gif" /> 
                English
            </a>
        </li>

        <li class="th">
            <a title="Switch to Thai language" href="http://domain/th">
                <img width="16" height="13" alt="Thai Language" src="flag-th.gif" /> 
                Thai
            </a>    
        </li>

        <li class="zh">         
            <a title="Switch to Chinese language" href="http://domain/zh">
                <img width="16" height="13" alt="Chinese Language" src="flag-zh.gif" /> 
                Chinese
            </a>
        <li>
    </ul>
</span>

CSS

ul#langlist {
    border:1px solid #3399CC;
    color:#006699;
    background:#fff;
    padding:0 !important;
    width:100px;
    list-style:none;
    position:absolute;
    top:62px;
    right:0;
    z-index:100;
    display:none;
}

span#langswitch:hover ul#langlist { display:block; }

But instead of the dropdown appearing aligned with my span, it’s appearing at the extreme right end of the browser. Here’s the screenshot.

alt text http://img84.imageshack.us/img84/1687/dropbox.png

Can any of the CSS gurus here recommend a fix for this?

Thanks,
m^e

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T20:55:39+00:00Added an answer on May 12, 2026 at 8:55 pm

    just set the position of the “span” to “relative”, set a fixed width to the “span” and play a bit with the values “top” and “left” (applied to #langlist) to manage the vertical and horizontal alignment of the list!


    EDIT (IN RESPONSE TO YOUR QUESTION): By default, when you place in a web page an element with an absolute position, its position (defined by the attributes “top” and “left”) is calculated relatively to the html page … so, the “left” and “top” values are the “x” and “y” coordinates of an apparent coordinate system whose origin is the top-left corner.

    For elements in the head of the webpage there is no problem (in the most of cases), but the elements absolutely positioned in the content of the page are constantly locked on their position so they don’t move with the content of the page if the user scrolls or resizes the web page!

    If you set to “relative” the position of the element (in this case the span) that contains the absolutely positioned tag, the values “top” and “left” are calculated relatively to this container, so the problem it’s fixed!

    ABOUT YOUR CODE: Technically you can’t apply the “hover” pseudo-class to non link elements if your Doctype is not HTML5, so my suggestion is to consider to use a jQuery function to apply “display: block” to the list when occurs an hover event on the #label. However, you can correct your code as follow … manage the distance of the list from the #label modifying the “margin-top” value of #langlist:

    <style type="text/css">
    #container{
        position: relative;
        width:100px;
    }
    
    #langswitch{
        padding: 0px;
        margin: 0px;
        list-style:none;
        position:absolute;
    }
    
    #langlist {
        border:1px solid #39C;
        color:#069;
        background:#fff;
        padding:0 !important;
        margin-top: 2px;
        width:100px;
        top:20px;
        left:0px; 
        display: none;
    }
    
    #container:hover #langlist{
        display:block;
    }
    
    img{
        background-color: #CCC;
        border: 1px solid black;
    }
    </style>
    
    
    <div id="container">
        <ul id="langswitch">
        <li>
            <a id="label" href="#">Language↓</a>
            <ul id="langlist">
            <li class="en">
                <a title="Current language: English" href="http://domain/en">
                    <img width="16" height="13" alt="English Language" src="flag-en.gif" /> 
                    English
                </a>
            </li>
    
            <li class="th">
                <a title="Switch to Thai language" href="http://domain/th">
                    <img width="16" height="13" alt="Thai Language" src="flag-th.gif" /> 
                    Thai
                </a>    
            </li>
    
            <li class="zh">                 
                <a title="Switch to Chinese language" href="http://domain/zh">
                    <img width="16" height="13" alt="Chinese Language" src="flag-zh.gif" /> 
                    Chinese
                </a>
            </li>
            </ul>
        </li>
        </ul>
    </div>
    

    Notice that this solution doesn’t work on IE6!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.