掬一捧清水,放逐在江河,融入流逝的岁月,将心洗净;

捻一缕心香,遥寄在云端,在最深的红尘里重逢,将心揉碎;

望一程山水,徘徊在月下,在相思渡口苦守寒冬,将心落寞。

案例一:

隐藏扩展域,并去掉after,并去掉高度

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.clearfix:after{ /*善用after和defore*/
content: "111"; /*注意加引号*/
clear: both;
display: block;
visibility: hidden; /*隐藏并有高度*/
height: 0; /*去掉高度*/ }
.c{
width: 100px;
/*height: 100px;*/
background-color:red;
}
.c .item{
float:left;
width:30px;
background-color: green ;
} </style>
</head>
<body>
<div class='c clearfix'>
<div class='item'>123</div>
<div class='item'>456</div> </div> <div class="test">内容</div>
</body>
</html>

更新后的代码

案例二:

当鼠标放在一个图片上显示这个商品的信息,或者一些别的东西,比如

.touch:hover .content{}

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.touch{
width: 200px;
height: 200px;
overflow: hidden;
position: relative;
}
.touch .content{
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0,.6);
color: white;
text-align: center;
visibility: hidden;
}
.touch:hover .content{
visibility: inherit;
} </style>
</head>
<body>
<div class="touch">
<div><img src="2.jpg"></div>
<div class="content">
<div class="c1">ALEX</div>
<div class="c1">500-1000(日)</div>
</div>
</div>
</body>
</html>

案例及代码

案例三:

要求在当前页面不超出多余内容,超出了变成滚动条显示

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
body{
margin: 0;
}
.pg_top{
height: 48px;
background-color: #dddddd;
}
.pg_body_menu{
position: absolute;
width: 180px;
background-color: blueviolet;
left: 0;
}
.pg_body_content{
position: absolute;
top: 48px;
left: 190px;
right: 0;
bottom: 0;
background-color: blueviolet;
overflow: auto; /*可以利用overflow变导航条*/
}
</style>
</head>
<body>
<div class="pg_top"> </div>
<div class="pg_body">
<div class="pg_body_menu">
<p>1</p><p>1</p><p>1</p><p>1</p><p>1</p>
<p>1</p><p>1</p><p>1</p><p>1</p><p>1</p>
<p>1</p><p>1</p><p>1</p><p>1</p><p>1</p>
</div>
<div class="pg_body_content">
<p>1</p><p>1</p><p>1</p><p>1</p><p>1</p>
<p>1</p><p>1</p><p>1</p><p>1</p><p>1</p>
<p>1</p><p>1</p><p>1</p><p>1</p><p>1</p>
<p>1</p><p>1</p><p>1</p><p>1</p><p>1</p>
<p>1</p><p>1</p><p>1</p><p>1</p><p>1</p>
<p>1</p><p>1</p><p>1</p><p>1</p><p>1</p>
</div>
</div> </body>
</html>

代码

案例四:

尖角图标,尖角符号是向上,当鼠标点的时候尖角符号向下

.c1{ /*这个是麻烦写法*/
border-top: 30px solid yellow ;
border-left: 30px solid green;
border-bottom: 30px solid blue;
border-right: 30px solid black;
display: inline-block;
}
.c1{ /*半个*/
border-top: 30px solid yellow ;
border-left: 30px solid green;
border-bottom: 0px solid blue;
border-right: 30px solid black;
display: inline-block;
}

部分代码-学习的第一阶段

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
/*.c1{ 这个是麻烦写法
border-top: 30px solid yellow ;
border-left: 30px solid green;
border-bottom: 0px solid blue;
border-right: 30px solid black;
display: inline-block;
}*/
.c1{
border: 30px solid transparent ;
border-top: 30px solid yellow ;
display: inline-block;
margin-top: 40px;
}
.c1:hover{
border: 30px solid transparent;
border-bottom: 30px solid yellow ;
margin-top:10px ;
}
</style>
</head>
<body>
<div style="height: 150px; background-color: red;">
<div class="c1"></div> </div>
</body>
</html>

代码

案例五:

模态对话框

就是弹出一个框,然后显示一些内容(其实是分为三层)

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
body{
margin: 0;
}
.model{
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: rgba(0,0,0,0.5);
z-index: 2;
}
.content{
height: 300px;
width: 400px;
background-color: white;
color: #000000;
position: fixed;
top: 50%;
left: 50%;
z-index: 3;
margin-left: -200px;
margin-top: -200px;
font-size:32px ;
line-height: 300px;
text-align: center;
}
</style>
</head>
<body>
<div style="height: 2000px; background-color: red;">
<h1>ads</h1><h1>ads</h1><h1>ads</h1><h1>ads</h1><h1>ads</h1>
<h1>ads</h1><h1>ads</h1><h1>ads</h1><h1>ads</h1><h1>ads</h1>
</div>
<div class="model"></div>
<div class="content">悲伤那么大!!!</div>
</body>
</html>

案例六:

输入框里面有图片

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.user{
position: relative;
width: 250px;
}
.user input{
height: 30px;
width: 150px;
padding-right: 20px; }
.user .ren{
position: absolute;
top: 8px;
left: 160px;
}
</style>
</head>
<body>
<div class="user">
<input type="text" />
<span class="ren">R<!--这里可以放图片--></span> </div>
</body>
</html>

代码

案例七:

商品加减框

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
body{
margin: 0;
}
.left{
float: left;
}
.wrap{
width: 150px;
height: 22px;
border: 1px solid #ddd;
/*background-color: red;*/
position: relative;
left: 100px;
top: 100px;
}
.wrap .minus{
height: 22px;
width: 22px;
line-height: 22px;
text-align: center;
}
.wrap .plus{
height: 22px;
width: 22px;
line-height: 22px;
text-align: center;
}
.wrap .count input{
padding: 0; /*input是有padding的*/
border: 0;
width: 104px;
height: 22px;
border-left: 1px solid #dddddd;
border-right: 1px solid #dddddd;
}
</style>
</head>
<body>
<div class="wrap">
<div class="minus left">-</div>
<div class="count left">
<input type="text" />
</div>
<div class="plus left">+</div>
</div>
</body>
</html>

代码

案例八:

商品加减框加减,鼠标并变化样式

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
body{
margin: 0;
}
.left{
float: left;
}
.wrap{
width: 150px;
height: 22px;
border: 1px solid #ddd;
/*background-color: red;*/
position: relative;
left: 100px;
top: 100px;
}
.wrap .minus{
height: 22px;
width: 22px;
line-height: 22px;
text-align: center;
cursor: pointer;
}
.wrap .plus{
height: 22px;
width: 22px;
line-height: 22px;
text-align: center;
cursor: pointer; /*当鼠标指的时候变样式*/
}
.wrap .count input{
padding: 0; /*input是有padding的*/
border: 0;
width: 104px;
height: 22px;
border-left: 1px solid #dddddd;
border-right: 1px solid #dddddd;
}
</style>
</head>
<body>
<div class="wrap">
<div class="minus left" onclick='Minus();'>-</div>
<div class="count left">
<input id='count' type="text" />
</div>
<div class="plus left" onclick='Plus();'>+</div>
</div>
<script type="text/javascript">
function Plus(){
var old_str = document.getElementById('count').value
var old_int = parseInt(old_str);
var new_int = old_int + 1
document.getElementById('count').value = new_int
}
function Minus(){
var old_str = document.getElementById('count').value
var old_int = parseInt(old_str);
var new_int = old_int - 1
document.getElementById('count').value = new_int
} </script>
</body>
</html>

代码

案例九:

当鼠标指到图片,会变成字体和边框颜色会变

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
.ele{
width: 300px;
height: 300px;
background-color: yellow;
}
.ccc{
width: 300px;
height: 200px;
background-color: green;
}
.ddd{
width: 300px;
height: 100px;
background-color: red;
}
.ele:hover .ddd{
background-color: blueviolet;
font-size: 38px;
}
</style>
</head>
<body>
<div class="ele">
<div class="ccc">图片1</div>
<div class="ddd">
ddd
</div>
</div>
</body>
</html>

代码

HTML前端--各种小案例的更多相关文章

  1. web前端开源小案例:立方体旋转

    HTML部分: <body class="body"> <div class="rect-wrap">   <!-- //舞台元素 ...

  2. C#开发微信门户及应用(47) - 整合Web API、微信后台管理及前端微信小程序的应用方案

    在微信开发中,我一直强调需要建立一个比较统一的Web API接口体系,以便实现数据的集中化,这样我们在常规的Web业务系统,Winform业务系统.微信应用.微信小程序.APP等方面,都可以直接调用基 ...

  3. 8天入门docker系列 —— 第五天 使用aspnetcore小案例熟悉容器互联和docker-compose一键部署

    这一篇继续完善webnotebook,如果你读过上一篇的内容,你应该知道怎么去挂载webnotebook日志和容器的远程访问,但是这些还远不够,webnotebook 总要和一些数据库打交道吧,比如说 ...

  4. JavaWeb_(Struts2框架)Ognl小案例查询帖子

    此系列博文基于同一个项目已上传至github 传送门 JavaWeb_(Struts2框架)Struts创建Action的三种方式 传送门 JavaWeb_(Struts2框架)struts.xml核 ...

  5. 机械表小案例之transform的应用

    这个小案例主要是对transform的应用. 时钟的3个表针分别是3个png图片,通过setInterval来让图片转动.时,分,秒的转动角度分别是30,6,6度. 首先,通过new Date函数获取 ...

  6. shell讲解-小案例

    shell讲解-小案例 一.文件拷贝输出检查 下面测试文件拷贝是否正常,如果cp命令并没有拷贝文件myfile到myfile.bak,则打印错误信息.注意错误信息中basename $0打印脚本名.如 ...

  7. [jQuery学习系列六]6-jQuery实际操作小案例

    前言最后在这里po上jQuery的几个小案例. Jquery例子1_占位符使用需求: 点击第一个按钮后 自动去check 后面是否有按钮没有选中, 如有则提示错误消息. <html> &l ...

  8. 02SpringMvc_springmvc快速入门小案例(XML版本)

    这篇文章中,我们要写一个入门案例,去整体了解整个SpringMVC. 先给出整个项目的结构图:

  9. React.js入门小案例

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title&g ...

随机推荐

  1. Set up gradle HiveMind

    HiveMind is a comprehensive ERP application for service organizations. It includes a project managem ...

  2. The first gui program by Qt

    #include<QApplication> #include<QPushButton> int main(int argc, char **argv) {     QAppl ...

  3. JWPlayer中字幕文件的配置

    最近应项目要求研究JWPlayer,视研究进度可能会将解决的问题或者一些配置方法写在这里. jwplayer支持vtt和srt格式的字幕文件,在视频中可以选择加载多个字幕文件(常用于多语言字幕),并且 ...

  4. 在CentOS上装 ElasticSearch

    参考官方文档:Install Elasticsearch with RPM ElasticSearch依赖Java,所以需要先安装Java: 到Oracle官网找到下载链接 http://www.or ...

  5. Java Filter过滤器的简单总结

    1.Filter的介绍 Filter技术是servlet 2.3新增加的功能.它能够对Servlet容器的请求和响应对象进行检查和修改. Filter本身并不生成请求和响应对象,只是提供过滤功能. F ...

  6. 【POJ 1273】Drainage Ditches(网络流)

    一直不明白为什么我的耗时几百毫秒,明明差不多的程序啊,我改来改去还是几百毫秒....一个小时后:明白了,原来把最大值0x3f(77)取0x3f3f3f3f就把时间缩短为16ms了.可是为什么原来那样没 ...

  7. 【CodeForces 520E】Pluses everywhere

    题意 n个数里插入k个+号,所有式子的和是多少(取模1000000007) (0 ≤ k < n ≤ 105). 分析 1.求答案,考虑每个数作为i位数(可为答案贡献10的i-1次方,个位i=1 ...

  8. POJ3579 Median

    Description Given N numbers, X1, X2, ... , XN, let us calculate the difference of every pair of numb ...

  9. FireFox插件

    Firebug和YSlow就不说了,太常用了,开发必备.

  10. SQL多条件查询

    SELECT a.tel,a.business_code,b.name AS business_name,a.register_time FROM T_RED_USER a LEFT JOIN T_P ...