关于css方面的技巧
2017-03-22 21:41 晓九已存在 阅读(133) 评论(0) 编辑 收藏 举报1.用span完成三角形的写法
span{
display: inline-block;
width: 0px;
height: 0px;
border: 10px solid transparent;
border-top: 10px solid #fff;
}
2.多行文字超出以......的实行显示
p{
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 11;
overflow: hidden;
text-overflow: ellipsis;
}
3.块状元素使vertical-align:middle有效的方法
父元素需要 vertical-align:middle
然后为元素before:{
content: "";
display: inline-block;
vertical-align: middle;
height: 100%;
}
需要居中的元素也vertical-align:middle;
4.元素水平垂直居中的方法
1.ele{
position: absolute;
left: 35%;
top: 55%;
margin-top: -320px;
margin-left: -130px;
}
2.css实现窗口变化时,元素仍然居中
.ele {
width: 50%;
margin: auto;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
chrome中文界面上会默认将小于12px的文本强制按照12px显示,解决方法:-webkit-text-size-adjust:none;
css样式重置代码
@charset "utf-8";
body{margin: 0;}
h1,h2,h3,h4,h5,h6{margin: 0;}
p{margin: 0;}
form{margin: 0;}
input,select{color: #333;margin: 0;padding: 0;border: none;outline: none;-webkit-appearance: none;}
textarea{padding: 0;border: none;outline: none;color: #333;resize: none;text-align: justify;}
a{color: #333;text-decoration: none;-webkit-tap-highlight-color: rgba(255,255,255,0);}
b{font-weight: normal;}
i{font-style: normal;}
ul,ol{margin: 0;padding: 0;}
li{list-style: none;}
img{border: 0;}
table{border-collapse: collapse;text-align: center;}
td,th{padding: 0;}
.clearfix:after{content: "";display: block;clear: both;height: 0;}
.clearfix{zoom: 1;}
.fl{float: left;}
.fr{float: right;}
关于手机端
<meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scale=no">
<meta name="applicable-device" content="mobile">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="address=no">
媒体查询 @media only screen and (min-width: 320px) and (max-width: 374px)