如何使用CSS制作3个垂直点?

时间:2015-05-15 12:59:35

标签: css css3

我希望在我的页面上有3个点,例如,切换上下文菜单的显示。如何使用CSS实现这一目标?

3-dots toggle animation gif

8 个答案:

答案 0 :(得分:59)

使用unicode char



.test:after {
  content: '\2807';
  font-size: 100px;
  }

<div class="test"></div>
&#13;
&#13;
&#13;

使用背景属性

&#13;
&#13;
div {
    width: 100px;
    height: 300px;
    background-image: radial-gradient(circle at center, black 10px, transparent 10px);
    background-size: 100px 100px;
}
&#13;
<div></div>
&#13;
&#13;
&#13;

阴影

&#13;
&#13;
div {
  width: 30px;
  height: 30px;
  border-radius: 50%;
    background-color: black;
  box-shadow: 0px 40px 0px black, 0px 80px 0px black;
}
&#13;
<div></div>
&#13;
&#13;
&#13;

伪元素

&#13;
&#13;
div {
  position: relative;
  width: 20px;
  height: 20px;
  background-color: black;
  border-radius: 50%;
}

div:before, div:after {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  left: 0px;
  background-color: inherit;
  border-radius: inherit;
  }

div:before {
  top: 40px;
  }


div:after {
  top: 80px;
}
&#13;
<div></div>
&#13;
&#13;
&#13;

答案 1 :(得分:16)

尝试3点菜单的完整源代码:

<强>的index.html

&#13;
&#13;
<!DOCTYPE html>
    <html>
        <head>
            <title>Three Dot Menu</title>

            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

            <style>
                *{margin: 0;padding:0px}

                .header{
                    width: 100%;
                    background-color: #0d77b6 !important;
                    height: 60px;
                }

                .showLeft{
                    background-color: #0d77b6 !important;
                    border:1px solid #0d77b6 !important;
                    text-shadow: none !important;
                    color:#fff !important;
                    padding:10px;
                }

                .icons li {
                    background: none repeat scroll 0 0 #fff;
                    height: 7px;
                    width: 7px;
                    line-height: 0;
                    list-style: none outside none;
                    margin-right: 15px;
                    margin-top: 3px;
                    vertical-align: top;
                    border-radius:50%;
                    pointer-events: none;
                }

                .btn-left {
                    left: 0.4em;
                }

                .btn-right {
                    right: 0.4em;
                }

                .btn-left, .btn-right {
                    position: absolute;
                    top: 0.24em;
                }

                .dropbtn {
                    background-color: #4CAF50;
                    position: fixed;
                    color: white;
                    font-size: 16px;
                    border: none;
                    cursor: pointer;
                }

                .dropbtn:hover, .dropbtn:focus {
                    background-color: #3e8e41;
                }

                .dropdown {
                    position: absolute;
                    display: inline-block;
                    right: 0.4em;
                }

                .dropdown-content {
                    display: none;
                    position: relative;
                    margin-top: 60px;
                    background-color: #f9f9f9;
                    min-width: 160px;
                    overflow: auto;
                    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
                    z-index: 1;
                }

                .dropdown-content a {
                    color: black;
                    padding: 12px 16px;
                    text-decoration: none;
                    display: block;
                }

                .dropdown a:hover {background-color: #f1f1f1}

                .show {display:block;}

            </style>
            <script>
                function changeLanguage(language) {
                    var element = document.getElementById("url");
                    element.value = language;
                    element.innerHTML = language;
                }

                function showDropdown() {
                    document.getElementById("myDropdown").classList.toggle("show");
                }

                // Close the dropdown if the user clicks outside of it
                window.onclick = function(event) {
                    if (!event.target.matches('.dropbtn')) {
                        var dropdowns = document.getElementsByClassName("dropdown-content");
                        var i;
                        for (i = 0; i < dropdowns.length; i++) {
                            var openDropdown = dropdowns[i];
                            if (openDropdown.classList.contains('show')) {
                                openDropdown.classList.remove('show');
                            }
                        }
                    }
                }
            </script>
        </head>
        <body>
            <div class="header">

                <!-- three dot menu -->
                <div class="dropdown">
                    <!-- three dots -->
                    <ul class="dropbtn icons btn-right showLeft" onclick="showDropdown()">
                        <li></li>
                        <li></li>
                        <li></li>
                    </ul>
                    <!-- menu -->
                    <div id="myDropdown" class="dropdown-content">
                        <a href="#home">Home</a>
                        <a href="#about">About</a>
                        <a href="#contact">Contact</a>
                    </div>
                </div>

            </div>
        </body>
    </html>
&#13;
&#13;
&#13;

答案 2 :(得分:5)

如果您使用font-awesome,它就像包含.fa-ellipsis-v样式一样简单。更多文档可在此处找到:http://fontawesome.io/icon/ellipsis-v/

答案 3 :(得分:2)

  1. 使用fontawesome.css

    <i class='fa fa-ellipsis-v'></i>
    
  2. 使用Glyphicons

    <span class="glyphicons glyphicons-option-vertical"></span>
    
  3. 使用css

    .textSpan:after {
     content: '\2807';
     font-size: 3em;
     color: #2e2e2e
    }
    

答案 4 :(得分:1)

<强> HTML

<div class="dot"></div>

<强>的CSS:

.dot{
    width: 10px;
    height: 10px;
    background: red;
    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    border-radius: 5px;
}

答案 5 :(得分:1)

Unicode包含⠇,它是字母“ U”的盲文符号。要使用,只需在代码中使用HTML实体&#10247;

答案 6 :(得分:1)

投票得最多的答案是用两列虚线表示,所以我用下面的Unicode字符完成了

<div>&#xFE19;</div>

答案 7 :(得分:-1)

<script> <meta name="viewport" content="width=device-width, initial-scale=1"/>
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"></link></script>

 <i class="fa fa-ellipsis-v col-2 mt-3 .text-light fa-lg" style={{"float":"right"}}></i>

可用于查看三个点。可用于反应中的卡片