Pure css close button

前端 未结 11 488
[愿得一人]
[愿得一人] 2020-12-12 19:51

JSFiddle

Is there any way to make something like the X on that link with pure css?

\"enter

相关标签:
11条回答
  • 2020-12-12 19:57

    Just a thought - if you're not targeting IE7, you could get away with any image being base64-encoded and embedded into css. I'm assuming your goal is to avoid an unnecessary http request rather than to actually make a css button as its own goal.

    0 讨论(0)
  • 2020-12-12 19:57

    If you want pure css, without the letter "x"....

    Here are some awesome experimental icons that include an "x" in a circle that is made with CSS: http://nicolasgallagher.com/pure-css-gui-icons/demo/

    0 讨论(0)
  • 2020-12-12 19:58

    I spent more time on this than I should have, and haven't tested in IE for obvious reasons. That being said, it's pretty much identical.

    http://jsfiddle.net/adzFe/14/

    a.boxclose{
        float:right;
        margin-top:-30px;
        margin-right:-30px;
        cursor:pointer;
        color: #fff;
        border: 1px solid #AEAEAE;
        border-radius: 30px;
        background: #605F61;
        font-size: 31px;
        font-weight: bold;
        display: inline-block;
        line-height: 0px;
        padding: 11px 3px;       
    }
    
    .boxclose:before {
        content: "×";
    }
    
    0 讨论(0)
  • 2020-12-12 19:59

    Edit: Updated css to match with what you have..

    DEMO

    HTML

    <div>
        <span class="close-btn"><a href="#">X</a></span>
    </div>
    

    CSS

    .close-btn {
        border: 2px solid #c2c2c2;
        position: relative;
        padding: 1px 5px;
        top: -20px;
        background-color: #605F61;
        left: 198px;
        border-radius: 20px;
    }
    
    .close-btn a {
        font-size: 15px;
        font-weight: bold;
        color: white;
        text-decoration: none;
    }
    
    0 讨论(0)
  • 2020-12-12 20:01

    I Think It Is Best!

    And Use The Simple JS to make this work.

    <script>
    function privacypolicy(){
        var privacypolicy1 = document.getElementById('privacypolicy');
        var privacypolicy2 = ('display: inline;');
        privacypolicy1.style= privacypolicy2;
    }
    function hideprivacypolicy(){
        var privacypolicy1 = document.getElementById('privacypolicy');
        var privacypolicy2 = ('display: none;');
        privacypolicy1.style= privacypolicy2;
    }
    </script>
    <style type="text/css">
                .orthi-textlightbox-background{
                    background-color: rgba(30, 23, 23, 0.82);
                    font-family: siyam rupali; 
                    position: fixed; top:0px; 
                    bottom:0px; 
                    right:0px; 
                    width: 100%; 
                    border: none; 
                    margin:0; 
                    padding:0; 
                    overflow: hidden; 
                    z-index:999999; 
                    height: 100%;
                    }
    
                    .orthi-textlightbox-area {
                    background-color: #fff;
                    position: absolute;
                    width: 50%;
                    left: 300px;
                    top: 200px;
                    padding: 20px 10px;
                    border-radius: 6px;
                    }
                    .orthi-textlightbox-area-close{
                    font-weight: bold;
                    background-color:black;
                    color: white;
                    border-radius: 50%;
                    padding: 10px;
                    float: right;
                    border: 1px solid black;
                    box-shadow: 0 0 10px 0 rgba(33, 157, 216, 0.82);
                    margin-top:-30px;
                    margin-right:-30px;
                    cursor:pointer;
                    }
    </style>
    <button onclick="privacypolicy()">Show Content</button>
    <div id="privacypolicy" class="orthi-textlightbox-background" style="display:none;">
    <div class="orthi-textlightbox-area">
    LOL<button class="orthi-textlightbox-area-close" onclick="hideprivacypolicy()">×</button>
    </div>
    </div>
    
    0 讨论(0)
  • 2020-12-12 20:06

    My attempt at a close icon, no text

    .close-icon
    {
      display:block;
      box-sizing:border-box;
      width:20px;
      height:20px;
      border-width:3px;
      border-style: solid;
      border-color:red;
      border-radius:100%;
      background: -webkit-linear-gradient(-45deg, transparent 0%, transparent 46%, white 46%,  white 56%,transparent 56%, transparent 100%), -webkit-linear-gradient(45deg, transparent 0%, transparent 46%, white 46%,  white 56%,transparent 56%, transparent 100%);
      background-color:red;
      box-shadow:0px 0px 5px 2px rgba(0,0,0,0.5);
      transition: all 0.3s ease;
    }
    <a href="#" class="close-icon"></a>

    0 讨论(0)
提交回复
热议问题