博主信息
博文 4
粉丝 0
评论 0
访问量 3382
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
css的定位,及伪选择器hover-第五期培训php-3.14
Yzw的博客
原创
888人浏览过


1.优酷顶部导航

实例

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>优酷-这世界很酷</title>
	<link rel="icon" type="img/x-icon" href="static/images/1.ico">
	<style type="text/css">
		*{margin: 0;padding: 0;}
		.header{
			position: relative;
	        width: 100%;
	        height: 422px;
	        background: 176,180,189;
	        
		}
		.content{
			width: 1200px;
			margin:0 auto;
		}
		.pic_show{
			margin: 0 auto;
			width: 1200px;
			height:422px;
			background: url(static/images/bg.jpg) no-repeat;
		}
		.bg{background: rgba(176,180,189,0.2);
			width: 100%;
			height: 100%;
			position: absolute;top: 0;left: 0;z-index: 99;}
		.logo{
			position: fixed;top: 20px;left:120PX;z-index: 100;
		}
		.logo form{
			width: 370px;
			height: 40px;
			position: relative;left: 290px;}
		.logo input{
			width: 370px;
			height: 40px;
			border: none;
			border-radius: 100px;
			background: rgba(234,234,234,0.3);
		}
		.logo button{
			position: absolute;top: 0;right: 0;
			width:80px;
			height: 40px;
			border-top-right-radius:30px;
			border-bottom-right-radius:30px;
			border:none;
			background: #1F82FC;
			color: #fff;
		}
		.box{float: left;}
		.clera{clear: both;}
	</style>
</head>
<body>
      <div class="header">
          <div class="pic_show"></div>
	         <div class="bg"></div>
	           <div class="logo">
	         	   <img src="static/images/logo.png" class="box">
	         	    <form class="box">
	                 	<input type="" name="">
	                 	<button>全网搜</button>
	                 </form>
	           </div>
	        <div class="clear"></div>        
      </div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

2.CSS中的定位(Position)属性允许你对元素进行定位;(fixed/relative/absolute)*/

A- fixed:元素的位置相对于浏览器窗口是固定位置.

B- relative:相对定位元素的定位是相对其正常位置,相对定位元素经常被用来作为绝对定位元素的容器块.

C- absolute:绝对定位的元素的位置相对于最近的已定位父元素,如果元素没有已定位的父元素,那么它的位置相对于出始包含块;特点:绝对定位使元素的位置与文档流无关,因此不占据空间.

D- z-index 属性设置元素的堆叠顺序 注意:Z-index 仅能在定位元素上奏效-子绝父相.

E~ :hover 选择器用于选择鼠标指针浮动在上面的元素

实例

<!DOCTYPE html>
<html>
<head>
<style>
div:hover
{
background-color:yellow;
}
</style>
</head>
<body>

<div>php</div>

</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


批改状态:合格

老师批语:作业要赶上进度!
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学