用户注册表单以及选择器权重与上下文选择器
16lz
2021-09-27
用户注册表单以及选择器权重与上下文选择器
一、from 用户注册表单
- 用户注册表单效果图
实例演示 from 用户注册表单
- 代码语言
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>常用表单</title>
</head>
<body>
<h2 class="ye">用户注册</h2>
<!-- http://127.0.0.1:5500/0922/tijiaofuwuqi.php =POST -->
<!-- http://127.0.0.1:5500/0922/dome.html?username= GET -->
<!-- 表单form用户注册 -->
<form action="tijiaofuwuqi.php" method="POST">
<!-- <fieldset></fieldset> 给表单元素周围加个边框 -->
<fieldset>
<legend style="text-align: center">必填项</legend>
<!-- 单行文本 -->
<!-- 绑定账号标签 -->
<div>
<label for="username"> 账号:</label>
<!-- 文本框 -->
<!-- *绑定ID -->
<input
type="text"
id="username"
name="username"
placeholder="不超过8位"
required
autofocus
value="1827673"
/>
</div>
<div>
<label for="password"> 密码:</label>
<input
type="password"
id="passtword"
name="password"
placeholder="不超过8位"
required
/>
<!-- 显示密码 -->
<!-- <button type="button" onclick="document.querySelector('#password').type='text'">显示密码</button> -->
<!-- 按钮 -->
</div>
<div>
<label for="email"> 邮箱:</label>
<input
type="email"
id="email"
name="email"
placeholder="demo@email.com"
required
/>
</div>
</fieldset>
<!-- 单选按钮 -->
<div>
<label for="secret">性别</label>
<!-- 单选按钮中的name属性,必须全部一样,才能保证返回唯一值 -->
<input type="radio" name="gender" id="male" value="male" /><label
for="male"
>男</label
>
<input type="radio" name="gender" id="female" value="female" /><label
for="female"
>女</label
>
<!-- checked布尔属性,不需要值,只要存在就是true -->
<input
type="radio"
name="gender"
id="secret"
value="secret"
checked
/><label for="secret">保密</label>
</div>
<!-- 复选框 -->
<!-- []表示数组,可以保存一组不同类型的数据,供后端使用 -->
<div>
<label>爱好</label>
<!-- 单选按钮中的name属性,必须全部一样,才能保证返回唯一值 -->
<input
type="checkbox"
name="hobby[]"
id="game"
value="game"
checked
/><label for="game">游戏</label>
<input type="checkbox" name="hobby[]" id="trave" value="trave" /><label
for="trave"
>旅游</label
>
<!-- checked布尔属性,不需要值,只要存在就是true -->
<input
type="checkbox"
name="hobby[]"
id="shoot"
value="shoot"
checked
/><label for="shoot">摄影</label>
</div>
<div>
<!-- 下拉列表,将变量名和多个值分开设置,由用户自己选择 -->
<!-- name,value应该在一个标签内,但是select -->
<select name="level">
<option value="1">铜牌会员</option>
<option value="2">银牌会员</option>
<option value="3" selected>金牌会员</option>
<option value="4">永久会员</option>
</select>
</div>
<!-- 自定义下拉列表 -->
<!-- datalist+ input -->
<div>
<label for="">搜索关键字:</label>
<input type="search" name="search" list="keywords" />
<datalist id="keywords">
<option value="html">html</option>
<option value="css">css</option>
<option value="css">css</option>
<option value="css">css</option>
</datalist>
</div>
<button>提交</button>
<!-- 重置按钮 重置不是清空-->
<button type="reset">重置</button>
</form>
</body>
</html>
二、选择器权重
选择器的特殊性值表述为 3 个部分,用 0,0,0 表示。或者百[id],十[class],个[tag]/标签
ID 选择器,1,0,0。
class 类选择器,0,1,0。
标签,0,0,1。
通配选择器*对特殊性没有贡献,即 0,0,0。
最后比较特殊的一个标志!important(权重),它没有特殊性值,但它的优先级是最高的,通常 !important 用在样式调试的时候 。
- 选择器权重效果图
实例演示 权重关系
- 代码语言
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>权重关系</title>
<style>
/* 选择当前的h3有三种选择器;
标签,class,id */
/* 将id,class,tag,想像成一个三位整数,初始为0,0,0 */
/* 百位 十位 个数 */
/* id class tag */
/* 0 0 0 */
/* 百位对应:id
十位对应:class
个位对应:tag */
/* 当前权重0,0,1 */
h3 {
background-color: burlywood;
}
/* 当前权重0,0,2 */
body h3 {
background-color: coral;
}
/* 当前权重0,0,3 */
html body h3 {
background-color: cornflowerblue;
}
/* 当前权重0,1,0 */
.b {
background-color: crimson;
}
/* 当前权重0,1,1 */
h3.b {
background-color: darkblue;
}
/* 当前权重1,0,0 */
#a {
background-color: darkorange;
}
/* 当前权重1,1,0 */
#a.b {
background-color: deeppink;
}
</style>
</head>
<body>
<!-- *权重关系 -->
<h3 id="a" class="b">人生苦短,我学PHP</h3>
</body>
</html>
三、上下文选择器
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>上下文选择器</title>
<style>
/* 子元素选择器 > */
.list > li {
border: 1px solid red;
}
/* 后代选择器 空格 */
.list li {
border: 1px solid black;
}
.list .liem {
background-color: aquamarine;
}
/* 相邻选择器 /下一个+ */
.list .liem + li {
background-color: bisque;
}
/* 所有兄弟选择器 */
.list .liem ~ * {
background-color: rebeccapurple;
}
</style>
</head>
<body>
<ul class="list">
<li>ltem1</li>
<li class="liem">ltem2</li>
<li>
ltem3
<!-- <ul>
<li>ltem1</li>
<li>ltem2</li>
</ul> -->
</li>
<li>ltem4</li>
<li>ltem5</li>
<li>ltem6</li>
<li>ltem7</li>
<li>ltem8</li>
</ul>
</body>
</html>
更多相关文章
- 表单制作和选择器
- HTML表单与选择器学习与应用
- html注册页面-表单
- 网站外链建设注意事项有哪些
- 域名对SEO优化到底有多大影响!
- 如何优化网站权重页?
- html表单、元素的来源及csss外部样式和上下文选择器
- html练习之表单标签使用
- HTML表单内容的详细介绍