📄 css0401.htm
字号:
<html>
<head>
<title>洪恩在线 - CSS教程</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="/pub/css/home.css">
<link rel="stylesheet" href="/pc/homepage/homepage.css">
<meta name="keywords" content="电脑乐园,电脑,乐园,交互教程,交互,教程,教育">
</head>
<body bgcolor="white" text="black" topmargin="10" leftmargin="0" marginwidth="0" marginheight="10">
<!--顶部开始-->
<script language="Javascript" src="/pub/js/head.js"></script>
<!--顶部结束-->
<table width="760" height="20" border=0 cellspacing="0" cellpadding="0" align="center">
<tr>
<td height=20 class="p1" bgcolor="#E8E8E8" align="left"><img src="/pc/img/blank.gif" width="12" height="8"><font color="#FF9966">当前位置</font>:<a href="/default.htm" class="under">洪恩在线</a>
-> <a href="/pc/index.htm" class="under">电脑乐园</a> -> CSS教程</td>
</tr>
</table>
<table width="760" border=0 cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="15"></td>
</tr>
</table>
<table width="760" cellspacing="0" border=0 cellpadding="0" align="center">
<tr>
<td width="145" valign="top" bgcolor="#E8E8E8" align="left" style="color:blue" class="p1" height="123">
<br>
<table width="145" border="0" cellspacing="0" cellpadding="0" bordercolor="#F8AC0E" height="20">
<tr bgcolor="000099" valign="middle">
<td width="115" align="center" class="p2"><b><font color="#FFFFFF">CSS教程</font></b></td>
<td height="20" bgcolor="#E8E8E8" width="13"><img src="/pc/img/title_00.gif" width="13" height="20"></td>
<td height="20" bgcolor="#E8E8E8" width="17"> </td>
</tr>
</table>
<p class="p1" style="line-height:17pt" align="left"> <font color="#CC3399">→</font>
<a href="css0101.htm">CSS快速入门</a><br>
<font color="#CC3399">→</font> <a href="css0201.htm">怎样编写CSS</a><br>
<font color="#CC3399">→</font> <a href="css0301.htm">CSS属性</a><br>
<font color="#CC3399">→</font> CSS定位<br>
1.动态转换<br>
2.<a href="css0402.htm">空间定位</a><br>
<font color="#CC3399">→</font> <a href="css0501.htm">CSS滤镜</a> <br>
<br>
</p>
<p align="center" class=p1><a href=/pc/bin/msg.pl?file_id=k_css target="_blank"><img src="/pc/img/message.gif" width="64" height="54" alt="请您留言" border="0"><br> 谈谈您的看法</a>
<br>
<script language="javascript">
speak_num="za"
</script>
<script language="javascript" src=/pc/var/pc_k_css.js>
</script>
<script language="javascript">
var num=0
if (!isNaN(speak_num)){
num=speak_num;
}
else{
num=0
}
document.writeln ("已有")
document.writeln (num)
document.writeln ("条发言")
</script>
</p>
<p class="p1" style="line-height:17pt" align="left"> </p>
</td>
<td width=1 bgcolor=#0586D7 height="123"><img src="/pc/img/blank.gif" width="1" height="1">
</td><td width=15 background="/pc/img/line.gif"><p> </p></td>
<td valign="top" background="/pc/img/line.gif" width="584" height="123" class="p2">
<p align="center"><b><span class="p3"><br>
<font color="#3366CC">四、CSS定位</font></span></b></p>
<p align="right" class="p1"> </p>
<hr color=blue size=1>
<p class="p2" style="line-height:17pt"> <b><font color="336633">1.动态转换</font></b></p>
<p class="p2" style="line-height:17pt"> 通过在CSS中设置属性,我们可以准确的定义一个页面的样式,如颜色、字体、边框等。现在我们要讲的CSS定位主要是在页面的布局和控制上进行定义,使您的页面从这两个方面都展现的非常完美,更加富有动感。
<br>
另外,在讲解之前,我们首先介绍两个定义:相对定位和绝对定位。相对定位就是允许在文档的原始位置上进行偏移。而绝对定位则允许任意定位。<br>
实现CSS的定位最终还是要靠属性。我们来看一下定位属性的详细列表(见下图):</p>
<p class="p2" style="line-height:17pt" align="center"><img src="img/css065.gif" width="430" height="174" border="0" alt="定位属性">
</p>
<p class="p2" style="line-height:17pt"> 我们在下面举一个例子,其中带了一点Script的内容,我们来看看它是如何实现动态显示的。讲解之前我们还是先看一下这个例子的效果吧,请<em class="p3"><a href="sl/dingwei.htm" target="_blank"><font color="#FF0033">点击这里</font></a></em><br>
看,通过简单的CSS定位实现了颇具动感的效果。这种效果的代码如下:</p>
<p class="p2" style="line-height:17pt"> <font color="#006666"><html><br>
<head><br>
<title>dingwei css</title> <br>
<style type=“text/css”> <br>
<!-- <br>
#container1{position:absolute;top:100}</font> <br>
<font color="CC33CC">//*定义container1 为绝对位置*//</font> <br>
<font color="#006666">#container2{position:absolute;top:100;visibility:hidden;}</font><br>
<font color="CC33CC">//*定义container2为绝对定位,初始可见度为hidden(隐藏)*//</font>
<br>
<font color="#006666">p{font-size:12pt;}</font><font color="CC33CC">//*定义p的字体*//</font><br>
<font color="#006666"> --> <br>
</style> <br>
</head> <br>
<body> <br>
<p style=“font-family:行书体;font-size:15pt;color:#cc33cc”></font>
<br>
请选择一幅图片: </p><font color="CC33CC">//*设置字体大小、名称、颜色*//</font>
<br>
<font color="#006666"> <div id=“container1”> <br>
<dd><img src=“ss01065.jpg” width=“185”height=“280”></font>
<font color="CC33CC"><br>
//*导入一张图片,标识符为container1*// </font><br>
<font color="#006666"><p style=“font-family:行书体;color:#cc9933;font-size:12pt”><br>
名称:大漠</p></font><font color="CC33CC">//*设置字体名称、颜色、大小*//</font>
<br>
<<font color="#006666">/dd> <br>
</div> <br>
<div id=“container2”><br>
<dd><img src=“ss01095.jpg” width=“185”height=“280”></font>
<font color="CC33CC"><br>
//*导入另一种图片,标识符为container2*//</font> <br>
<font color="#006666"><p style=“font-family:行书体;color:#3366cc;font-size:12pt”><br>
名称: 大海</p> <br>
</dd> <br>
</div> <br>
<form name=“myform”></font><font color="CC33CC">//*定义两个按钮*//</font>
<br>
<font color="#006666"><p><input type=“button” value=“大漠”
<br>
onclick=“container1.style.visibility=‘visible’;<br>
container2.style.visibility=‘hidden’”></font> <br>
<font color="CC33CC">//*定义鼠标点击事件图片1为可见,图片2为不可见*//</font> <br>
<font color="#006666"><input type=“button” value=“大海”;<br>
container1.style.visibility=‘hidden’; <br>
onclick=“container2.style.visibility=‘visible’; <br>
container1.style.visibility=‘hidden’”></p></font> <br>
<font color="CC33CC">//*定义鼠标点击事件图片1为不可见,图片2为可见*//</font> <br>
<font color="#006666"></form><br>
</body> <br>
</html></font></p>
<p class="p2" style="line-height:17pt"> 代码虽然长了一些,但结构很简单,您只要用心看注释,很容易理解的。下一节我将向您继续介绍一个CSS定位的例子。
</p>
<hr color=blue size=1>
<p class="p1" align="right"><a href="css0310.htm">上一节</a> <a href="css0402.htm">下一节</a> </p>
<p> </p>
<p align="center" class=p2><a href=/pc/bin/msg.pl?file_id=k_css target="_blank"><img src="/pc/img/message.gif" width="64" height="54" alt="请您留言" border="0"><br> 谈谈您的看法</a>
<script language="javascript">
speak_num="za"
</script>
<script language="javascript" src=/pc/var/pc_k_css.js>
</script>
<script language="javascript">
var num=0
if (!isNaN(speak_num)){
num=speak_num;
}
else{
num=0
}
document.writeln ("已有")
document.writeln (num)
document.writeln ("条发言")
</script>
</p>
<p> </p></td><td width=15 background="/pc/img/line.gif"><p> </p></td>
</tr>
</table>
<!--底部开始-->
<script language="Javascript" src="/pub/js/foot.js"></script>
<!--底部结束-->
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -