CSS3总结

1、圆角边框和阴影

1、圆角边框border-radius
分为4个属性:
border-top-left-radius:1px 2px;
border-top-right-radius:2px 4px;
border-bottom-left-radius:4px 8px;
border-bottom-right-radius:4px 8px;

border-radius:水平值 垂直值;
border-radius:1px; 表示长半轴短半轴一样长。

2、阴影box-shadow
inset 水平偏移 垂直偏移 模糊距离 颜色
  inset 可选,内部阴影
  outset 默认值 外部阴影

example:
box-shadow: 10px 10px 5px #888;
box-shadow: inset 10px 10px 5px #888;

 2、文字和文本

1、text-shadow属性
text-shadow:水平偏移 垂直偏移 阴影大小 颜色;
<h1>Web design</h1>
h1{
text-shadow:2px 2px 3px blue;
}

2、word-wrap属性
 normal
 break-word

word-wrap:break-word;   允许长单词自动换行

3、@font-face规则
利用@font-face规则,定义web字体,并引用
需要字体的四种文件格式,确保能在主流浏览器中都能正常显示该字体。
.TTF/.OTF
.EOT
.SVG
.WOFF

步骤: 1)下载字体,假设只有一种TTF格式
      2)可利用 www.fontsquirrel.com/tools/webfont-
生成其他格式的字体。
      3)建立fonts文件夹存放字体文件
      4)之后引用字体文件

example:

<!DOCTYPE html>
<html>
<head>
	<style> 
		@font-face{
		font-family: kastlerFont;
		src:url('fonts/kastler.ttf'),
		    url('fonts/kastler.eot'),
		    url('fonts/kastler.woff'),
		    url('fonts/kastler.svg');
		}
		p{
		font-family:kastlerFont;
		}
	</style>
</head>
<body>
<p>Web front-end development</p>


</body>
</html>

3、2D转换 

1、旋转
transform:rotate(30deg);
单位deg,正数表示顺时针,负数表示逆时针

2、缩放
transform:scale(x,y);
x:水平方向缩放倍数
y:垂直方向缩放倍数
0~1:缩小 >1:放大

.box:hover{
  transform:scale(1.2);
}
x,y同时放大1.2

在sublime中使用 trf 扩展

4、 过渡与动画

1、过渡 transition属性
transition-property:要过渡的属性名
transition-duration: 持续时间
transition-timing-function:过渡函数
transition-delay:延时

transition: 属性名 持续时间 过渡方法
trs扩展

transition-timing-function属性取值
linear      匀速
ease        慢快慢
ease-in     慢快
ease-out    快慢
ease-in-out 慢快慢

div{
color:#000;
background-color:#123;
transition: all 1s linear;
}
div:hover{
color:#999
backgroud-color:white;
}

2、animation动画
  1)定义动画:keyframes规则
  2)调用动画:animation属性

@keyframes mycolor
{
    0% {background-color:red;}
    30% {background-color:blue;}
    60% {background-color:yellow;}
    100% {background-color:green;}
}
div:hover{
    animation:mycolor 5s linear;
}

animation属性取值:
animation-name :   引用keyframes动画的名称
animation-duration: 动画完成时间
animation-timing-function:默认ease
animation-play-state: running/paused

5、3d变换 

1、3d变换
首先声明
transform-style:preserve-3d;

2、旋转
x轴:向右
y轴:向上
z轴:向外
transform:rotateX(30deg);

3、透视
perspective 属性,眼睛离舞台的距离
perspective:100px;
离的越远,近大远小的效果越不明显,因为越远光线越接近平行

example:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>3D</title>
	<style> 
	#stage{
		width: 300px;
		margin: 100px auto;
		perspective:200px;
	}
	.box{
		width: 100px;
        height:100px;
        float:left; 
        transition:linear 1s;
        transform-style: preserve-3d;
	}
	img
	{
		width:100px;
		height:75px;
	}
	.x:hover
	{		
		transform:rotateX(60deg);
	}
	.y:hover
	{		
		transform:rotateY(60deg);
	}
	.z:hover
	{		
		transform:rotateZ(60deg);
	}
	</style>

</head>
<body>
<div id="stage">
	<div class="box x">
		<img src="frog.jpg" />
	</div>
	<div class="box y">
		<img src="frog.jpg" />
	</div>
	<div class="box z">
		<img src="frog.jpg" />
	</div>
</div>
</body>
</html>

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CSS transform 3D是一种CSS属性,用于实现在网页中对元素进行3D转换和动画效果。通过使用transform属性的rotateX、rotateY、rotateZ、translateX、translateY、translateZ、scaleX、scaleY、scaleZ等方法,可以实现元素的旋转、平移、缩放等3D效果。 在使用CSS transform 3D时,可以通过设置perspective属性来确定网页中的元素是2D变换还是3D变换。perspective属性规定了透视效果,决定了元素在页面上的显示效果。如果没有定义perspective属性,就没有3D效果。perspective属性可以在父元素上设置,也可以在当前元素上设置。 在CSS代码中,perspective属性可以使用具体的数值来设置透视点的大小,也可以使用perspective()函数来设置。通过设置perspective属性,可以调整元素的视觉效果,使其看起来更具有立体感。 通过使用CSS transform 3D的方法,可以实现元素在x轴、y轴和z轴上的缩放效果。在示例代码中,通过设置scaleX、scaleY和scaleZ方法,可以分别实现元素在x轴、y轴和z轴上的缩放效果。当鼠标悬停在元素上时,通过设置:hover伪类和transform属性,可以触发缩放效果。 总结来说,CSS transform 3D是一种用于实现网页元素3D转换和动画效果的CSS属性。通过设置transform属性的方法,可以实现元素的旋转、平移和缩放等3D效果。通过设置perspective属性,可以调整元素的透视效果,使其看起来更具有立体感。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [CSS3的transform之3d转换、CSS3动画](https://blog.csdn.net/m0_46324704/article/details/125860882)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [css:transform的3D变换属性](https://blog.csdn.net/qq_50487248/article/details/130066660)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值