X close button only using css

后端 未结 8 1575
感情败类
感情败类 2020-12-25 10:21

How to make a cross (X) only in css3, to use as a close button ?

I\'ve been searching since long time, i cannot found how.... When i look at source code on website u

8条回答
  •  别那么骄傲
    2020-12-25 11:01

    Here's some variety for you with several sizes and hover animations.. demo(link)

    enter image description here

    • Large
    • Medium
    • Small
    • Switch

    css

    .ele div.x {
    -webkit-transition-duration:0.5s;
      transition-duration:0.5s;
    }
    
    .ele div.x.slow {
    -webkit-transition-duration:1s;
      transition-duration:1s;
    }
    
    ul { list-style:none;float:left;display:block;width:100%; }
    li { display:inline;width:25%;float:left; }
    .ele { width:25%;display:inline; }
    .x {
      float:left;
      position:relative;
      margin:0;
      padding:0;
      overflow:hidden;
      background:#CCC;
      border-radius:2px;
      border:solid 2px #FFF;
      transition: all .3s ease-out;
      cursor:pointer;
    }
    .x.large { 
      width:30px;
      height:30px;
    }
    
    .x.medium {
      width:20px;
      height:20px;
    }
    
    .x.small {
      width:10px;
      height:10px;
    }
    
    .x.switch {
      width:15px;
      height:15px;
    }
    .x.grow {
    
    }
    
    .x.spin:hover{
      background:#BB3333;
      transform: rotate(180deg);
    }
    .x.flop:hover{
      background:#BB3333;
      transform: rotate(90deg);
    }
    .x.t:hover{
      background:#BB3333;
      transform: rotate(45deg);
    }
    .x.shift:hover{
      background:#BB3333;
    }
    
    .x b{
      display:block;
      position:absolute;
      height:0;
      width:0;
      padding:0;
      margin:0;
    }
    .x.small b {
      border:solid 5px rgba(255,255,255,0);
    }
    .x.medium b {
      border:solid 10px rgba(255,255,255,0);
    }
    .x.large b {
      border:solid 15px rgba(255,255,255,0);
    }
    .x.switch b {
      border:solid 10px rgba(255,255,255,0);
    }
    
    .x b:nth-child(1){
      border-top-color:#FFF;
      top:-2px;
    }
    .x b:nth-child(2){
      border-left-color:#FFF;
      left:-2px;
    }
    .x b:nth-child(3){
      border-bottom-color:#FFF;
      bottom:-2px;
    }
    .x b:nth-child(4){
      border-right-color:#FFF;
      right:-2px;
    }
    

提交回复
热议问题