简单实例:登录表单、后台架构
发布于:2022-04-18 13:44:24
次阅读
1、登录表单
代码
<form action="check.php" method="post"> <div> <!-- type, name, value --> <!-- autofocus: 布尔属性 --> <!-- label.for = input.id (绑定) --> <label for="username">用户名:</label> <input type="text" id="username" name="user" value="" placeholder="至少5个字母" autofocus required/> </div> <div> <label for="psw">密码:</label> <input type="password" id="psw" name="password" value="" placeholder="字母+数字" required/> </div> <div> <label for="my-email">邮箱:</label> <input type="email" id="my-email" name="email" value="" placeholder="a@emil" required/> </div> <div> <label for="male">性别:</label> <!-- 所有input.name 必须相同 --> <input type="radio" id="male" name="gender" checked/><label for="male">男</label> <input type="radio" id="female" name="gender"/><label for="female">女</label> </div> <div> <label>爱好:</label> <!-- 所有input.name 必须是一个数组格式 --> <input type="checkbox" name="hobbies[]" id="shoot" checked/><label for="shoot">摄影</label> <input type="checkbox" name="hobbies[]" id="program" checked/><label for="program">编程</label> <input type="checkbox" name="hobbies[]" id="game"/><label for="game">游戏</label> </div> <div> <!-- 下拉列表 --> <!-- select.name, option.value , name,value属性不在同一个标签中 --> <label for="user">会员:</label> <select name="user" id="user"> <option value="1">金牌会员</option> <option value="2">银牌会员</option> <option value="3" selected>铜牌会员</option> <option value="4">木牌会员</option> </select> </div> <div> <!-- 多行文本框 --> <textarea name="" id="" cols="30" rows="10"></textarea> </div> <div> <button>提交</button> </div></form>
效果

2、简单后台框架
代码
<style> body{ height: 100vh; width: 100vw; display: grid; grid-template-columns: 10em 1fr; grid-template-rows: 6em 1fr; margin: 0; } body .header{ grid-column-end: span 2; background-color:aquamarine; border-bottom: 1px solid currentColor; padding: 2em; display:flex; align-items:center; } body .header div{ margin-left:auto; } body .nav { background-color:aqua; margin:0; padding-top:1em; list-style:none; } body iframe{ width: calc( 100vw - 10em); height: calc(100vh - 6em); border-left: 1px solid currentColor; }</style><body> <div class="header"> <h1>后台管理</h1> <div> <span>admin</span> <a href="">退出</a> </div> </div> <!-- ul.nav>li*5>a[href="demo$.html" target="content"]{菜单项$} --> <ul class="nav"> <li><a href="demo1.html" target="content">菜单项1</a></li> <li><a href="demo2.html" target="content">菜单项2</a></li> <li><a href="demo3.html" target="content">菜单项3</a></li> <li><a href="demo4.html" target="content">菜单项4</a></li> <li><a href="demo5.html" target="content">菜单项5</a></li> </ul> <iframe srcdoc="" frameborder="2" name="content"></iframe></body>
效果

3、实例演示元素样式来源与优先级
代码
<body> <!-- 来源1: 代理样式/浏览器样式/默认样式 --> <h2>h2默认样式/浏览器样式</h2> <!-- 来源2: 自定义样式, 会覆盖默认样式 --> <h2 style="color: red">h2自定义样式,会覆盖默认样式</h2> <!-- 来源3: 书写顺序,写在后面的同名属性会覆盖前面的(优先级相同的情况下) --> <h2 style="color:blue">写在后面的同名属性会覆盖前面的(优先级相同的情况下)</h2> <div style="color:blueviolet"> <!-- 某些属性具有继承特征,例如颜色,字号,字体,子元素会继承父元素的同名属性 --> <h2>某些属性具有继承特征,例如颜色,字号,字体,子元素会继承父元素的同名属性</h2> </div> </body>
效果
