css应用技巧

【动态按钮】

效果图
//vue

<el-button :class="{'night': runModelText === '运行模式'}" type="primary" icon="el-icon-coordinate" size="mini"  >
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <b @click="runModel"   >{{ runModelText }} </b>
        </el-button>

//样式
.night{
    position: relative!important;
    /* color: rgb(18, 190, 243); */
    /* letter-spacing: 12px; */
    text-align: center;
    /* background-color: rgb(31, 49, 133); */
    /* background-image: linear-gradient(90deg, rgb(40, 62, 161) 50%,rgb(31, 49, 133) 50% ); */
    /* text-transform: uppercase; */
    user-select: none;
    text-decoration: none;
    overflow: hidden;
    box-shadow: inset 0 0 10px rgb(14, 84, 105),
    0 0 5px rgb(9, 208, 235);
    transition: all 0.5s;
    
}
.night:hover{
    text-shadow: 0 0 5px rgb(18, 190, 243),
    0 0 8px rgb(18, 190, 243),
    0 0 10px rgb(18, 190, 243); 
    /* background-image: linear-gradient(90deg, rgb(25, 38, 99) 50%,rgb(13, 22, 58) 50% ); */
    box-shadow: inset 0 0 10px rgb(14, 20, 105),
    0 0 5px rgb(9, 208, 235),
    0 0 10px rgb(9, 208, 235);
}
    
.night span{
    position: absolute!important;   
}
.night span:nth-child(1){
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-image: linear-gradient(to right, transparent , rgb(132, 230, 255));
    animation: button_move1 2s linear infinite;
}
@keyframes button_move1 {
    0%{
        transform: translateX(-100%);
    }
    100%{
        transform: translateX(100%);
    }
}
.night span:nth-child(2){
    top: 0;
    right: 0;
    width: 2px;
    height: 100%;
    transform: translateY(-100%);
    background-image: linear-gradient(to bottom,  transparent ,  rgb(132, 230, 255) );            
    animation: button_move2 2s linear infinite;
    animation-delay: 1s;
}
@keyframes button_move2 {
   
    100%{
        transform: translateY(100%);
    }
}
.night span:nth-child(3){
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background-image: linear-gradient(to left, transparent , rgb(132, 230, 255)  );
    animation: button_move3 2s linear infinite;
}
@keyframes button_move3 {
    0%{
        transform: translateX(100%);
    }
    100%{
        transform: translateX(-100%);
    }
}
.night span:nth-child(4){
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    transform: translateY(100%);
    background-image: linear-gradient(to top, transparent , rgb(132, 230, 255) );
    animation: move4 2s linear infinite;
    animation-delay: 1s;
}
@keyframes move4 {
    100%{
        transform: translateY(-100%);
    }
}

【斜角按钮】

效果图
//html
//斜角按钮
<a class="title_button">信号机</a>
<a class="title_button_on">POM4</a>

//css
//斜角按钮
.title_button,.title_button_on{
    position: relative;
    display: inline-block;
    margin: 0 1px;
    padding: 0 15px;
    color: white;
    font-size: 14px;
  } 
  .title_button::before{
    background: #06479e;//默认背景色
    z-index: -1;//避免背景把按钮挡住
    position: absolute;
    content: '';
    top: 0;left: 0;right: 0;bottom: 0;
    transform: skewX(27deg);
  }

  .title_button_on::before,.title_button:hover::before{
    background: #035fdb;//鼠标移过及选中背景色
    z-index: -1;//避免背景把按钮挡住
    position: absolute;
    content: '';
    top: 0;left: 0;right: 0;bottom: 0;
    transform: skewX(27deg);
  }

开始是有效果的,后来发现失效了,所以放弃了伪类的写法,改为下面写法

//html
<span class="title_button"  ><b></b><a >信号机</a></span>
<span class="title_button_on"  ><b></b><a >INOM</a></span>

//css
//斜角按钮
.title_button,.title_button_on{
    position: relative;
    display: inline-block;
    margin: 0 1px;
    padding: 0 15px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    height: 23px;
  } 
  .title_button a,.title_button_on a{
    z-index: 2;
    position: relative;
  } 
  .title_button b{
    width:100%;
    display: block;
    background: #06479e;
    z-index: 1;
    position: absolute;
    top: 0;left: 0;right: 0;bottom: 0;
    transform: skewX(27deg);
  } 
  .title_button_on b,.title_button:hover b{
    background: #035fdb;
    z-index: 1;
    position: absolute;
    top: 0;left: 0;right: 0;bottom: 0;
    transform: skewX(27deg);
  }

【常用表格样式】

image.png
<table class="mytable">
                  <tr>
                    <th >控制组 </th>
                    <th >最大采样 </th>
                    <th>最大缓存空间 </th>
                    <th>所控通道</th>
                  </tr>
                <tr>
                    <td >组1</td>
                    <td>4444</td>
                    <td>5676575</td>
                    <td>89098</td>
                </tr>
                </table>

表格样式

.mytable
        {
            border-radius: 20px;
            width: 100%;
            border-collapse: collapse;
            margin: 0 auto;
            text-align: center;
        }
        .mytable td, .mytable th
        {
            border: 1px solid #5f6f9c;
            color: #fff;
            padding: 10px;
        }
        
        .mytable th
        {
            background-color: #4a5986;
            color: #93a2cd;
        }
        .mytable tr:nth-child(odd)
        {
            background: #445177;
        }
        .mytable tr:nth-child(even)
        {
            background: #445177;
            
        }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容