初扫css笔记-1

css选择器

1、id选择器 #red{color:red} <p id="red"></p>

2、类选择器 .red{color:red} <p class="red"></p>

3、属性选择器 [title]{color:red} <p title="css"></p>

4、属性和值选择器 [title=myTitle]{color:red} <p title="myTitle"></p><p title="css"></p>样式只有在前者起作用

 

插入样式表

1、外部样式表

<link rel="stylesheet" type="text/css" href="mycss.css"/>

2、内部样式表

注:单个文档需要特殊样式时使用(在<head>标签内部)

<html>

<head>

<style type="text/css">

hr{color:red}

</style>

</head>

<body>

</body>

</html>

3、内联样式

<html>

<head>

</head>

<body>

<p style="color:red;margin-left:20px">this is a paragraph</p>

</body>

</html>

 

css设置背景

1、背景颜色

p{background-color:gray;}

2、背景图片

p{background-image:url(/path/img.gif);}

 

css背景关联

若文档较长,当文档向下滚动时,背景图片也会随之滚动,当文档滚动超过图像的位置时,图像就会消失。

解决方案:

       通过设置 background-attachment属性防止滚动

body{

    background-image:url(/path/img.gif);

    background-attachment:fixed 

    }

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值