CSS
CSS
一、左右布局:左边定宽、右边自适应,不少于3种方法
下面是几种方法:
1、利用flex
HTML
-
<div class="use-flex">
-
<div class="col1"></div>
-
<div class="col2"></div>
-
</div>
css
-
.use-flex{
-
display:flex;
-
display:-webkit-flex;
-
}
-
.col1{
-
background-color:green;
-
height:300px;
-
width:100px;
-
flex-shrink:0;
-
}
-
.col2{
-
background-color: red;
-
width:100px;
-
flex-grow:1;
-
}
2、 利用position:absolute
HTML
-
<div class="container">
-
<div class="col1"></div>
-
<div class="col2"></div>
-
</div>
- css
-
.container{
-
position:relative;
-
}
-
.col1{
-
position:absolute;
-
left:0;
-
top:0;
-
background-color: green;
-
width:100px;
-
height:300px;
-
}
-
.col2{
-
padding-left:100px;
-
background-color: red;
-
height:300px;
-
}
3、利用table布局
HTML
-
<table>
-
<tr>
-
<td class="col1"></td>
-
<td class="col2"></td>
-
</tr>
-
</table>
- css
-
table{
-
width:100%;
-
height:300px;
-
}
-
.col1{
-
width:100px;
-
background-color: green;
-
}
-
.col2{
-
background-color: red;
-
}
4、使用float
HTML
-
<div class="container">
-
<div class="col1"></div>
-
<div class="col2">dfd</div>
-
</div>
- css
-
.container{
-
overflow:hidden;
-
zoom:1;
-
}
-
.col1{
-
background-color: green;
-
width:100px;
-
height:300px;
-
float:left;
-
}
-
.col2{
-
margin-left:100px;
-
background-color: red;
-
height:300px;
-
}
二、css3用过哪些新特性
新特性有:
-
border-radius
圆角,@font-face
字体,box-shadow
text-shadow
框和文本的阴影 -
word-wrap
,background-size
,background-origin
,border-image
,box-sizing
,calc
,linear-gradient
等等 -
transform
转换- 2D 转换
-
rotate
旋转,图片转个90或180度什么的 -
translate
位置移动 -
scale
,skew
,matrix
等
-
- 3D 转换
-
rotate(XYZ)
根据x,y,z轴旋转 -
translate(XYZ)
,scale(XYZ)
同理 -
perspective
透视,这个很多3D效果都要设置一下,不然3D还是只会有”2D”的效果
-
- 2D 转换
-
transition
: 过渡,简单的动画(如:移个位置,变个长短),直接用这个属性就能搞定。 -
animation
: 动画,3D可以调用硬件渲染。 - 新的长度单位:
rem
,ch
,vw
,vh
,vmax
,vmin
等。其中ch:数字“0”的宽度,vw 相对于视窗的宽度:视窗宽度是100vw. -
clip-path
: 绘制路径,类似SVG
技术。 国外炫酷产品。 -
flex
:flex
布局,继table
和div
后的趋势,不了解或不熟悉的可以参考cssreference。 - 伪类选择器:如:
:target
,:enabled
,:disabed
,:first-child
,last-child
等等 -
@media
媒体查询,适用于一些响应式布局中 -
columns
: 分栏布局。 -
will-change
: 改善渲染性能, 参考使用CSS3 will-change提高页面滚动、动画等渲染性能。
input 的值