css随笔

一、position用法及作用

1.语法格式(设置在style样式中)

position:[样式值];

2.常用属性值的作用

static:默认值;
fixed:使得html元素脱离文档流飘起来,相对于浏览器窗口定位的;
relative:不会使html脱离文档流,相对于原来位置定位;
absolute:脱离文档流,飘起来,相对于第一个position值为非static的父标签进行定位;

3.脱离文档流后具体位置锁定

position: relative; right:10px;bottom: 10px;//表示相对于自身原来的位置距离右边和底边均为10px;

4.图片插入(引入素材)

<img src="../img/1.jpg" style="width: 960px;height: 356px;">

5.cursor属性

cursor:pointer;//鼠标扶上变手指

6.line-height

line-height:[与设置的height相同时,可实现垂直居中];

7.line-height与font的冲突

html中,当有line-height属性时,font属性不能缩写;否则垂直居中会失效
解决方法:

	font:[字体大小值]/[line-height值];如:font:10px/70px ;

8.margin属性

		<div style=" margin-bottom:150px; background-color: red; width: 300px; height: 100px;"></div>
		<div style="margin-top: 50px; background-color: blue;width: 300px; height: 100px;">
		
		<i style=" margin-right:150px; background-color: red; width: 300px; height: 100px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i>
		<i style=" margin-left:150px; background-color: lightblue; width: 300px; height: 100px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i>

上下两块级元素之间同时设置间距,会冲突,默认选择较大的那个;
左右两行内元素之间同时设置间距,则会直接叠加;无冲突;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值