前端常用小样式

- 项目初始化样式

rest.css

*{-webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box;}
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,button,textarea,p,blockquote,th,td { margin:0; padding:0;}
body { color:rgba(51,51,51,0.8); font-size:14px; font-family: "Arial","Microsoft YaHei","黑体","宋体",sans-serif; }
td,th,caption { font-size:14px; }
h1, h2, h3, h4, h5, h6 { font-weight:normal; font-size:100%; }
address, caption, cite, code, dfn, em, strong, th, var { font-style:normal; font-weight:normal;}
a { color:#555; text-decoration:none; }
a:hover { text-decoration: none; }
img { border:none; vertical-align: middle}
ol,ul,li { list-style:none; }
i{font-style: normal;}
input, textarea, select, button { font:14px "Arial","Microsoft YaHei","黑体","宋体",sans-serif;}
input,button{border: none; outline: none;}
input[type=checkbox], input[type=radio]{margin: 0;}
table { border-collapse:collapse; }
html {overflow-y: scroll;}
p{margin: 0;}
.clearfix:after {content: "."; display: block; height:0; clear:both; visibility: hidden;}
.clearfix { *zoom:1; }/*公共类*/

- 右箭头

.right_arrow {
    width: 3px;
    height: 3px;
    border-top: 0.05rem solid #747c8f;
    border-right: 0.05rem solid #747c8f;
	transform: translateY(-50%) rotate(45deg);
    -webkit-transform: translateY(-50%) rotate(45deg);
    -moz-transform: translateY(-50%) rotate(45deg);
    -ms-transform: translateY(-50%) rotate(45deg);
    -o-transform: translateY(-50%) rotate(45deg);
}

- 选中框样式

.handle input[type="checkbox"] {
  width: 0.6rem;
  height: 0.6rem;
  margin-right: 0.3rem;
  -webkit-appearance: none;
  background-image: url(../images/check.png);
  background-repeat: no-repeat;
  background-size: cover;
  background-size: 1.2rem;
  background-position: 0;
}

.handle input[type="checkbox"]:checked {
  background-position: -0.6rem 0.09rem;
  background-size: 1.2rem;
}

- 字体换行(末尾加…)

/* 单换行 */
.ellipsis-1 {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    word-break: break-all;
}


/* 双换行 */
.ellipsis-2 {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

- 不同大小字体底端对齐(为每个需要对齐的子元素都加上这个)

.box{
    vertical-align: bottom;
    display: inline-block;
}

- 背景渐变

#grad {
  background: -webkit-linear-gradient(left, red , blue); 
  background: -o-linear-gradient(right, red, blue); 
  background: -moz-linear-gradient(right, red, blue);
  background: linear-gradient(to right, red , blue); 
}

- 文字前后的线

h3.title span:before, h3.title span:after {
     content: '';                 /*CSS伪类用法*/
     position: absolute;         /*定位背景横线的位置*/
     top: 52%;
    /* background: #494949;       宽和高做出来的背景横线*/
     width: 9%;
     height: 2px;
 }
 h3.title span:before{
     left: 25%;        /*调整背景横线的左右距离*/
     background:linear-gradient(to left,#b6b6b6,#efefef);
 }
 h3.title span:after {
     right: 25%;
     background:linear-gradient(to left,#efefef,#b6b6b6);
 }

- H5拆红包效果

H5拆红包效果
在这里插入图片描述在这里插入图片描述在这里插入图片描述

- 根据X轴旋转

.test{
}

- background-img的设置

.test{
    background-image:url("");
    background-position: center center;
    background-repeat: no-repeat;
    -webkit-background-size:cover;
    -moz-background-size:cover;
    background-size:cover;
}

- 用layer.open实现的简单的图片查看

在这里插入图片描述

JS部分

    // 查看大图
    function showImg(url) {
        //alert(url);
        var showImg = '<div class="showImg">' +
            '<img class="main_img" src="' + url + '" alt="">' +
            '<img class="close" "closeLayer()" src="__STATIC__/images/close_white.png" alt="">' +
            '</div>'
        layer.open({       
            type: 1,
            closeBtn: 1,
            className: 'noBg',
            title: false,
            shadeClose: true,
            content: showImg
        });   

    }

    // 关闭layer
    function closeLayer() {
        layer.closeAll();
    }

CSS部分:


/* 弹出层图片,配合layeropen使用 */

.showImg {
    width: 90%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    overflow: hidden;
}

.noBg {
    background-color: rgba(0, 0, 0, 0);
}

.showImg .main_img {
    width: 100%;
    height: auto;
}

.showImg .close {
    width: 1rem;
    height: 1rem;
    margin: 1rem auto;
}

- 回到顶部按钮

 <a onclick="$('html,body').animate({'scrollTop':0},600)" id="topup" style="display: inline;">
        <img src="__STATIC__/images/topup.png" style="display: block;width: 1.45rem;height:1.45rem;">
    </a>

- jq绑定的onclick失效

在对应的css中添加一个手型

.test{
    cursor:pointer
}

- 下拉框样式

select {
  appearance: none;
  -moz-appearance: none;
  -webkit-appearance: none;
  border: 2px solid #d4d4d4;
  outline: none;
  background-color: #fff;
  height: 1.5rem;
  line-height: 1.5rem;
  padding: 0 0.8rem 0 0.48rem;
  border-radius: 0.2400rem;
  background: url("../images/dg.png") no-repeat scroll right center transparent;
  background-position-x: 95%;
}

- 滚动条样式

/*滚动条样式*/
.active_content-phone .phone-content::-webkit-scrollbar {
  /*滚动条整体样式*/
  width: 4px;
  /*高宽分别对应横竖滚动条的尺寸*/
  height: 4px;
}

.active_content-phone .phone-content::-webkit-scrollbar-thumb {
  /*滚动条里面小方块*/
  border-radius: 5px;
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.2);
}

.active_content-phone .phone-content::-webkit-scrollbar-track {
  /*滚动条里面轨道*/
  -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.1);
}

css换行,英文换行

.box{
	word-wrap: break-word;
}

吸顶容器

.sticky {
  position: -webkit-sticky;
  position: -moz-sticky;
  position: -ms-sticky;
  position: sticky;
  top: 0;
  z-index: 888;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值