html 和 css 中的样式语言选择按钮

lka*_*las 1 html css select button

我想为我的网站设计一个语言选择按钮。这是它应该是什么样子的设计:

语言选择按钮

我正在使用 Bootstrap 3。

我怎样才能做到这一点?任何帮助表示赞赏!

编辑

通过使用 css+jquery 创建自定义下拉列表来解决它,请参阅下面的结果。

lka*_*las 7

有许多无用的评论和反对票。无用的评论也应该有 downvote 选项。

至少给出一些建议会有所帮助。

但无论如何,我的问题得到了解决

<!DOCTYPE html>
<html>
    <head>
        <title>Custom dropdown</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <!-- Font Awesome CSS -->
        <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">        
        <!-- Latest compiled and minified Bootstrap CSS -->
        <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <!-- jQuery library -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <!-- Latest compiled Bootstrap JavaScript -->
        <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <!-- Google font -->
        <link href="https://fonts.googleapis.com/css?family=Raleway|Rancho" rel="stylesheet">

        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->

        <style>

            /* Custom dropdown */
            .custom-sel a {
                text-decoration: none;
                text-transform: uppercase;
                margin: 0;
                padding: 10px;
                text-align: left;
                font-family: Raleway;
                color: #546e7a;
                font-size: 15px;
                font-weight: 700;
                line-height: 24px;
                display: block;
            }

            .custom-sel a:hover {
                text-decoration: none;
                background-color: #EDF0F2;
                color: #ffffff;
            }

            .custom-sel a.selected {
                background-color: transparent;
            }

            .custom-sel a.selected:hover {
                background-color: transparent;
                color: #546e7a;
            }

            .hidden {
                display: none;
            }

            .lightblue {
                color:#03a9f4;
                margin-left: -4px;
            }

            .show-sel {
                background-color: #ffffff;
                box-shadow: -5px 0px 65px 0px rgba(0, 0, 0, 0.18);
            }

            .custom-sel {
                margin: 30px;
                display: inline-block;
            }
            /* Custom dropdown */

        </style>

        <script type="text/javascript">

            $(document).ready(function () {

                // Show dropdown
                $('.selected').click(function () {
                    $('.custom-sel').addClass('show-sel');
                    $('.custom-sel a').removeClass('hidden');
                });

                // Hide dropdown when not focused
                $('.custom-sel').focusout(function () {
                    $('.custom-sel').removeClass('show-sel');
                    $('.custom-sel a:not(:first)').addClass('hidden');
                }).blur(function () {
                    $('.custom-sel').removeClass('show-sel');
                    $('.custom-sel a:not(:first)').addClass('hidden');
                });

            });

        </script>

    </head>
    <body>
        <div class="container">

            <!-- Custom dropdown -->
            <div class="custom-sel">
                <a class="selected" href="#">ENG &nbsp;<i class="fa fa-caret-down lightblue" aria-hidden="true"></i></a>
                <a class="hidden" href="#">EST</a>
                <a class="hidden" href="#">RUS</a>
                <a class="hidden" href="#">FIN</a>
            </div>

        </div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是我目前满意的结果:https : //jsfiddle.net/manb0hzh/