CSS3 HTML5学习心得

1.字符串
str.charAt(字符串索引),若索引超过字符串长度,返回空。
str.indexof(“某字符”),找到这个字符顺序第一次出现的索引。
str.lastIndexof(“某字符”),找到某字符串倒序最后出现的索引,若没有返回-1。
str.Uppercase(),将str转换为大写。
str.Lowercase(),将str转换为小写。
str.substr(2,3),从索引为2开始,向后取3个字符。
str.substring(2,5),取索引[2,5)的字符。str.substring(5,2)和前者结果一样。
str.slice(2,5),取索引[2,5)的字符。str.slice(5,2)返回空,不能这么写。
str=”welcome”,str.split(“e”),以e分割它,得到[“w”,”locm”,”“]。

2.date
var d=new Date();
var year=d.getFullYear();//年
var month=d.getMonth();//月
var date=d.getDate();//日
var hour=d.getHours();//时
var minute=d.getMinutes();//分
var second=d.getSeconds();//秒
var milliseconds=d.getMilliseconds();//毫秒
可以得到当前的时间。
月份要加1,如果你想得到3月,那么输入的是2。
日期具有自动更正的效果。如果你想知道2012年2月多少天,那么var d=new Date(2012,2,0)。

3.css3新增
01 :root{
font-size:62.5%;
}设置整个页面的文字大小为16px默认*62.5%=10px。

02 rem,直接设置文字和根元素大小相比,em是和它的父级相比。

03 新增选择器:
:first-child,父元素第一个子元素。
:last-child,父元素最后一个子元素。
:nth-child(3),父元素的第3个子元素。
:nth-last-child(3),父元素的倒数第3个子元素。
:nth-child(3n+1),父元素的第1,4,7…个子元素。
:nth-child(even/add),父元素的偶/奇数个子元素。
以上的前提是父元素后面全是这一种子元素,若还有其他类型不同的元素,还要选到它们则要使用type。用法和child原理一样。

04 伪类
input{
outline: none;/* 将浏览器默认的轮廓样式清除 */
}
input:focus{
border:1px solid red;
}
input获取焦点时改变input边框样式,input此时type为text。
input:enabled{
border:1px solid blue;
}
input处于可用状态时改变input边框样式,input此时type为text。
input:disabled{
border:1px dashed pink;
}
input处于不可用时改变input边框样式,input此时type为text。
input:checked{
margin-right: 20px;
}
input处于选中状态时改变input边框样式,input此时type为checkbox。

body ::selection{
font-size:3rem;
color:red;
text-decoration: line-through;
font-weight: bold;
};选中状态,就是ctrl+a那种选中样子。

input:read-only{
font-size:3rem;
color:#ff7300;
}
input处于只读时改变input边框样式,input此时type为text。
readonly和disabled区别
表单元素被提交的两个条件:
1.元素必须是enabled
2.元素必须有name属性
就是disabled不能被提交。

04.属性选择器

属性选择器
div[class]{
color:red;
}选到 所有具有class属性的div

div[id=”hello”]{
color:red;
} 选到 所有具有id叫hello的div
div[id^=”he”]{
color:red;
} 选到 所有具有id以he开头的div
div[id$=”d”]{
color:red;
} 选到 所有具有id以d结尾的div

p :not(span){
color:red;
}选到父级p下面除了span以外所有标签。

05.表单设置
.tab{
width:604px;
border-spacing:0px;/* 清除单元格的间距 ,相当于cellspancing*/
border-collapse: collapse;/* 折叠 表单内表框重合 */
}

06.新增文本样式
文字添加阴影:text-shadow:15px(x轴) 5px(y轴) 5px(模糊大小) #3cf(颜色), -5px -5px 3px #f00(可以重复写,逗号隔开);

        文本超出隐藏,配合white-space,overflow使用
        white-space: nowrap;/* 超出不换行 */
        overflow: hidden;/* 超出部分隐藏 */
        text-overflow:ellipsis;默认clip,ellipsis(超出部分“...”表示。)

07.图片边框
border-image: url(images/border.png) 26(切割位置)/26px(图片边框的宽度) round;
图片必须是特定的才能用。

08.变形
.itany1{
transform:translate(100px,-50px);
} div的class叫.itany1的,向x轴移动100px,y轴移动-50px。

.itany2{
transform:scale(0.8,1);
} div的class叫.itany2的,横向缩小0.8,纵向不变。

.itany3{
transform:rotate(-30deg);
} div的class叫.itany3的,沿中心转-30度。

.itany4{
transform:skew(30deg,-10deg);
} x倾斜30度,y倾斜-10度。

.itany5{
transform:translate(100px,50px) rotate(45deg) skew(30deg);
} 也可以写在一起。

.itany3{
transform:rotate(-30deg);
transform-origin:top right;
} div的class叫.itany3的,沿右上方转-30度。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值