HTML5的重要内容-1
HTML学习笔记-1
(一):first-child和:first-of-type
:first-child第一个元素
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>选择器</title>
<style type="text/css">
p:first-child{
color: red;
}
</style>
</head>
<body>
<p>sssssssss</p>
<p>ddddddddd</p>
</body>
</html>
:first-of-type第一个某种类型元素
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>选择器</title>
<style type="text/css">
/*.div1 :first-child{
color: red;
}*/
.div1 :first-of-type{
color: red;
}
</style>
</head>
<body>
<div class="div1">
<h2>我是班长</h2><!-- 在第一个div中h2中是第一次出现的类型 -->
<h1>我是班长的朋友</h1><!-- 在第一个div中h1中是第一次出现的类型 -->
<div class="div1">
<h1>我是学位</h1><!-- 在第二个div中h1中是第一次出现的类型 -->
<h2>woshiss</h2><!-- 在第二个div中h2中是第一次出现的类型 -->
</div>
<h2>s;a;dlkl;</h2><!-- 在第一个div中h2中是第二次出现的类型 -->
<h1>dsdpppp</h1><!-- 在第一个div中h1中是第二次出现的类型 -->
</div>
</body>
</html>
(二):only-child和:only-of-type
:only-child只有一个孩子才会变
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>选择器</title>
<style type="text/css">
.div1 :only-child{
color: red;
}
/*.div1 :first-of-type{
color: red;
}*/
</style>
</head>
<body>
<!-- div不是有一个孩子,不会变红 -->
<div class="div1">
<h2>我是班长</h2>
<h1>我是班长的朋友</h1>
<div class="div1">
<h1>我是学位</h1>
<h2>woshiss</h2>
</div>
<h2>s;a;dlkl;</h2>
<h1>dsdpppp</h1>
</div>
</body>
</html>
:only-of-type一种类型只有一个的时候才会变
在第一个div中h2有三个h1有一个所以h1会变
在第二个div中h1/h2都是一个
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>选择器</title>
<style type="text/css">
/*.div1 :only-child{
color: red;
}*/
.div1 :only-of-type{
color: red;
}
</style>
</head>
<body>
<div class="div1">
<h2>我是班长</h2>
<h1>我是班长的朋友</h1>
<div class="div1">
<h1>我是学位</h1>
<h2>woshiss</h2>
</div>
<h2>s;a;dlkl;</h2>
<h2>dsdpppp</h2>
</div>
</body>
</html>
表单的伪类
(一)input:required
input:require{
border:solid 1px red
}
###(二)input:optional###
input:optional{
border:solid 1px red
}
(三)input:valid
input:valid{
background-color:white;
border:solid 1px red;
outline:none;
}
(四)input:invalid
input:valid{
background-color:white;
border:solid 1px green;
outline:none;
}
类元素
(一):before和:after
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>选择器</title>
<style type="text/css">
p{
font-size: 2em;
}
p:before{
content: "";
display: inline-block;
width: 1.5em;
height: 1.5em;
border-radius:50%;
position: relative;
top: 45px;
left: 15px;
background-color: #C39;
}
p:after{
content: "";
display: inline-block;
width: 1.5em;
height: 1.5em;
border-radius:50%;
position: relative;
top: 45px;
left: 15px;
background-color: #C39;
}
</style>
</head>
<body>
<p>>-<</p>
</body>
</html>
权重
!important 权重:无穷
内联样式(style属性) 权重:1000
id 100
class/属性选择器/伪类 10
标签选择器/伪元素 1
通配符 0
文本-初步-字体
(一)设置字体名称
font-family属性,定义文本的字体
body{font-family:sans-serif;}
h1{font-family:Georgis,serif}
(二)设置字体倾斜
font-style属性,最常用于倾斜文本
三个属性值
normal:文本正常显示
italic:文本倾斜显示
oblique:文本倾斜显示
例子
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>选择器</title>
<style type="text/css">
p.normal{
font-style: normal;
}
p.italic{
font-style: italic;
}
p.oblique{
font-style: oblique;
}
</style>
</head>
<body>
<p class="normal">wewewew</p>
<p class="italic">wewewew</p>
<p class="oblique">wewewew</p>
</body>
</html>
(三)设置字体加粗
font-weight属性,设置粗细
使用bold关键字可以设置粗体
关键字100-900为字体指定9级加粗,100最细,900最粗,400相当于normal,700相当于bold
例子
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>选择器</title>
<style type="text/css">
p.normal{
font-weight: bold;
}
p.italic{
font-weight: normal;
}
p.oblique{
font-style: 900;
}
</style>
</head>
<body>
<p class="normal">wewewew</p>
<p class="italic">wewewew</p>
<p class="oblique">wewewew</p>
</body>
</html>
(四)设置字体大小
font-size,所有css单位都可以作为值
###(五)组合定义###
font属性,设置组合字体样式,必须设置字体与大小
字体必须放在最后,因为字体是可以设置多个的
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>选择器</title>
<style type="text/css">
p{
font:bold italic 40px Georgia;
}
</style>
</head>
<body>
<p class="normal">wewewew</p>
<p class="italic">wewewew</p>
<p class="oblique">wewewew</p>
</body>
</html>
html颜色
p{color:red}
p{color:#ffff}
p{color:rgb(0,0,255)}//红绿蓝
p{color:rgba(0,0,255,0.5)}//红绿蓝,透明度
p{color:transparent;}//完全透明
html单位
%:百分比
in:英寸
cm:厘米
mm:毫米
em:1em等于当前字体尺寸,2em等于当前字体的两倍
ex:一个ex是一个字体的x-height。(x-height通常是字体尺寸的一半)
pt:磅(1pt等于1/72英寸)
PC:12点活字
Px:像素
HTML5的重要内容-1的更多相关文章
- 取消chrome浏览器下input和textarea的默认样式;html5默认input内容清除“×”按钮去除办法
取消chrome浏览器下input和textarea的默认样式: outline:none;/*清空chrome中input的外边框*/ html5默认input内容清除“×”按钮去除办法: inpu ...
- 将HTML5 Canvas的内容保存为图片借助toDataURL实现
将HTML5 Canvas的内容保存为图片主要思想是借助Canvas自己的API - toDataURL()来实现,具体实现如下,感兴趣的朋友可以参考下哈,希望对你有所帮助 <html> ...
- HTML5+CSS3新增内容总结!!!!!绝对干货
说到H5C3会不会觉得东西好多啊,今天就整理了一份总结性的内容: CSS3选择器有哪些?答:属性选择器.伪类选择器.伪元素选择器.CSS3新特性有哪些?答:1.颜色:新增RGBA,HSLA模式 文字阴 ...
- HTML5的核心内容
开发者可以放心地使用html5的理由 兼容性.HTML5在老版本的浏览器可以正常运行,同时支持HTML5的新浏览器也能正常运行HTML4,用HTML4创建出来的网站不是必须全部重建的. 实用性.HTM ...
- 将HTML5 Canvas的内容保存为图片
主要思想是借助Canvas自己的API - toDataURL()来实现,整个实现 HTML + JavaScript的代码很简单. 代码如下: <html> <meta http- ...
- 学习笔记之html5相关内容
写一下昨天学习的html5的相关内容,首先谈下初次接触html5的感受.以前总是听说html5是如何的强大,如何的将要改变世界.总是充满了神秘感.首先来谈一下我接触的第一个属性是 input的里面的 ...
- HTML5 介绍
本篇主要介绍HTML5规范的内容和页面上的架构变动. 目录 1. HTML5介绍 1.1 介绍 1.2 内容 1.3 浏览器支持情况 2. 创建HTML5页面 2.1 <!DOCTYPE> ...
- HTML最新标准HTML5小结
写在前面 HTML5出来已经很久了,然而由于本人不是专业搞前端的,只知道有这个东西,具体概念有点模糊(其实就是一系列标准规范啦):因此去年(2015.11.09),专门对HTML5做了个简单的小结,今 ...
- HTML5和CSS3基础教程(第8版)-读书笔记
第1章 网页的构造块 一个网页主要包括以下三个部分: n 文本内容(text content):在页面上让访问者了解页面内容的纯文字. n 对其他文件的引用(referen ...
- 深入理解HTML5:语义、标准与样式(勇猛精进早登大师殿堂创最优品质交互)
深入理解HTML5:语义.标准与样式(勇猛精进早登大师殿堂创最优品质交互) [美]布拉德福(Bradford,A.) [美]海涅(Haine,P.)著 高京译 ISBN 978-7-121-20552 ...
随机推荐
- 【环境搭建】phpstudy显示目录列表
问题来源 新版本的PHPStudy访问127.0.0.1不再像以前版本一样显示目录列表了 解决办法 打开vhosts.conf 将图中标记出来的一行Options FollowSymLinks Exe ...
- ChatGPT帮助工程师写代码:从功能模块完善到成功执行,实现需求
在软件开发过程中,经常会遇到需要完善功能模块.调试代码和解决问题的情况.为了提高效率,我们可以借助人工智能技术,例如OpenAI的ChatGPT语言模型,来协助我们进行代码编写和调试.本文将介绍一个案 ...
- MIT6.s081/6.828 lectrue1:Introduction and examples
目前课程官网能够查到 2020,2021.2022 秋季的课程表,但是视频都是 2020 年录制的那一版 简单复习+回顾下自己的 OS 学习之旅 参考资料: 官网:https://pdos.csail ...
- fread()模板
char buf[1<<20],*p1,*p2;#define GC (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin ...
- CRM系统化整合从N-1做减法实践
1 背景 京销易系统已经接入大网.KA以及云仓三个条线商机,每个条线商机规则差异比较大,当前现状是独立实现三套系统分别做支撑. 2 目标 2022年下半年CRM目标是完成9个新条线业务接入,完成销售过 ...
- k8s+containerd安装
准备环境 准备两台服务器节点,如果需要安装虚拟机,可以参考<wmware和centos安装过程> 机器名 IP 角色 CPU 内存 centos01 192.168.109.130 mas ...
- chrome pre 自动换行
问题引出 当我想要使用chrome的打印功能生成一份关于md的pdf版本的时候发现有的代码块没有自动换行,生成的PDF没有自动换行,导致部分信息无法阅读 处理方式 把有自动换行的部分处理一下,在md文 ...
- 关于bzoj3306(树)的一些反思
1.加零大法好,用好没烦恼 2.不要瞎开long long 3.万物皆可变成wa 4.如果超时,试图把循环中中的东西拉到外面来
- Swiper.vue?56a2:132 Uncaught DOMException: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
错误代码 解决方案 删除div标签.修改后,如下所示:
- Hugging News #0731: 新课程重磅发布、用户交流群邀请你加入、真实图像编辑方法 LEDTIS 来啦!
每一周,我们的同事都会向社区的成员们发布一些关于 Hugging Face 相关的更新,包括我们的产品和平台更新.社区活动.学习资源和内容更新.开源库和模型更新等,我们将其称之为「Hugging Ne ...