css3相关

1 浏览器兼容属性
transition:1s; //相当于JS中的animation
-webkit-transition://Chrome
-moz-transition: //FireFox
-o-transition: //opera
-ms-transition //IE
类似属性有:gradient(渐变)

2选择器
p:nth-child(2n):{background:red}//选择p标签父级元素下第2n个元素,并且这些元素还是p元素,若其中不是p元素,则样式不改变
p:nth-last-child(2n)://从后往前
p:nth-of-type(2)//选择p标签父级元素下第2个p元素

body *:nth-of-type(2)//选择body下所有类型各自的第二个元素
例如:

body *:nth-of-type(2){background: red;}
p{ width: 100%; height: 30px;}
<body>
        <p>p1</p>
        <h1>h1</h1>
        <p>p2</p>
        <h1>h2</h1>
        <p>p3</p>
        <h1>h3</h1>
        <p>p4</p>
        <h1>h4</h1>
</body>

first-chilid===nth-child(1)
last-chilid===nth-last-child(1)
first-of-type===nth-of-type(1)
last-of-type===nth-last-of-type(1)

3伪类应用
模拟单选框

<style>
label{ float:left;margin:0 5px; overflow:hidden; position:relative;}
label input{ position:absolute;left:-50px;top:-50px;}
span{float:left;width:50px;height:50px;border:3px solid #000;}
input:checked~span {background:red;}//关键
</style>
<body>
<label>
    <input type="radio" name="tab" />
    <span></span>
</label>
<label>
    <input type="radio" name="tab" />
    <span></span>
</label>
<label>
    <input type="radio" name="tab" />
    <span></span>
</label>
</body>

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值