精彩专题推荐:建站之入门课 建站之必修课 建站之关键课 网站价值所在 流量提高专题 css+div 标准 个人网站打造全过程
返回建站学首页
导航:
建站首页 | 网站设计 | 网站开发 | 网站运营 | 网页软件 | 建站指南 | 搜索优化 | 图像处理 | 视频教程 | 书籍教程 | 建站专题
当前位置:首页>网站设计>css教程>正文

CSS实例讲解:地图提示


来源:蓝色理想 时间:07-03-06 点击: 点击这里收藏本文
首先我们要显示5部分内容,内容结构相似,我们可以选用无序列表来显示介绍的图片和内容:

 

<ul>
  <li><a id="map01" href="#map01"><img src="/articleimg/2007/03/4514/map1.jpg" alt="Post Office" />This is the Popsville community <strong>Post Office</strong>, your home of over-priced postage. Click map for more</a></li>
  <li><a id="map02" href="#map02"><img src="/articleimg/2007/03/4514/map2.jpg" alt="Dew Drop Inn" />Home is where the beer is. And that means the <strong>Dew Drop Inn</strong>. Live music on the weekends. Click map for more</a></li>
  <li><a id="map03" href="#map03"><img src="/articleimg/2007/03/4514/map3.jpg" alt="River Beach" />Spend lazy summer afternoons at the beautiful <strong>River Beach</strong>. Hang out on the nude beach. Click map for more</a></li>
  <li><a id="map04" href="#map04"><img src="/articleimg/2007/03/4514/map4.jpg" alt="Woodland Traders" />Our local <strong>Woodland Traders</strong> is a veritable Mecca of consumer goods and hardware. Click map for more</a></li>
  <li><a id="map05" href="#map05"><img src="/articleimg/2007/03/4514/map5.jpg" alt="Wild Game Diner" />Country living means road kill, and the <strong>Wild Game Diner</strong> prepares it with special sauce. Click map for more</a></li>
</ul>

对于a中的内容我们进行隐藏,我们考虑增加span元素来实现,代码修改如下:

<ul>
  <li><a id="map01" href="#map01"><span class="offset"><img src="/articleimg/2007/03/4514/map1.jpg" alt="Post Office" />This is the Popsville community <strong>Post Office</strong>, your home of over-priced postage. Click map for more</span></a></li>
  <li><a id="map02" href="#map02"><span class="offset"><img src="/articleimg/2007/03/4514/map2.jpg" alt="Dew Drop Inn" />Home is where the beer is. And that means the <strong>Dew Drop Inn</strong>. Live music on the weekends. Click map for more</span></a></li>
  <li><a id="map03" href="#map03"><span class="offset"><img src="/articleimg/2007/03/4514/map3.jpg" alt="River Beach" />Spend lazy summer afternoons at the beautiful <strong>River Beach</strong>. Hang out on the nude beach. Click map for more</span></a></li>
  <li><a id="map04" href="#map04"><span class="offset"><img src="/articleimg/2007/03/4514/map4.jpg" alt="Woodland Traders" />Our local <strong>Woodland Traders</strong> is a veritable Mecca of consumer goods and hardware. Click map for more</span></a></li>
  <li><a id="map05" href="#map05"><span class="offset"><img src="/articleimg/2007/03/4514/map5.jpg" alt="Wild Game Diner" />Country living means road kill, and the <strong>Wild Game Diner</strong> prepares it with special sauce. Click map for more</span></a></li>
</ul>

在显示的时候文字会跟着图片排版,为了方便我们对其中的描述文字进行样式调整而不影响图片的布局,我们单独给描述文字增加span元素,代码修改如下:

<ul>
  <li><a id="map01" href="#map01"><span class="offset"><img src="/articleimg/2007/03/4514/map1.jpg" alt="Post Office" /><span>This is the Popsville community <strong>Post Office</strong>, your home of over-priced postage. Click map for more</span></span></a></li>
  <li><a id="map02" href="#map02"><span class="offset"><img src="/articleimg/2007/03/4514/map2.jpg" alt="Dew Drop Inn" /><span>Home is where the beer is. And that means the <strong>Dew Drop Inn</strong>. Live music on the weekends. Click map for more</span></span></a></li>
  <li><a id="map03" href="#map03"><span class="offset"><img src="/articleimg/2007/03/4514/map3.jpg" alt="River Beach" /><span>Spend lazy summer afternoons at the beautiful <strong>River Beach</strong>. Hang out on the nude beach. Click map for more</span></span></a></li>
  <li><a id="map04" href="#map04"><span class="offset"><img src="/articleimg/2007/03/4514/map4.jpg" alt="Woodland Traders" /><span>Our local <strong>Woodland Traders</strong> is a veritable Mecca of consumer goods and hardware. Click map for more</span></span></a></li>
  <li><a id="map05" href="#map05"><span class="offset"><img src="/articleimg/2007/03/4514/map5.jpg" alt="Wild Game Diner" /><span>Country living means road kill, and the <strong>Wild Game Diner</strong> prepares it with special sauce. Click map for more</span></span></a></li>
</ul>

XHTML部分我们已经写好,下面将是我们对其表现的设计部分,即CSS部分。

首先我们清除一下元素默认的边距(内边距和外边距)和设置img的默认边框为0:

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

我们定义下ul的样式,包括ul的预设标记,大小,高度,边框:

ul {
  list-style-type:none;
  background: transparent url(/articleimg/2007/03/4514/map_flat.jpg) no-repeat 0 0;
  width:350px;
  height:250px;
  border:1px solid #000;
}

对于li的显示方式设置内联(display: inline;)行布局

ul li {
  display:inline;
}

下面是我们讲解的重点,隐藏/显示效果。

对li中的a元素我们设置其块元素显示(display: block;),让其相对位置(position: relative;),并使链接不显示下划线。

ul li a {
  position:relative;
  display:block;
  text-decoration:none;
}

让类选择器为offset的span隐藏,至于怎样隐藏文章开头已经分析了:

ul li a span.offset {
  position:absolute;
  margin-top:-9000px;
  margin-left:-9000px;
}

如上已经实现了内容隐藏,现在我们制作考虑触发显示的效果:

ul li a:hover span.offset, ul li a:focus span.offset, ul li a:active span.offset {
  color: #000;
  background-image:none;
  background-color:#ffffde;
  border:1px solid #000;
  display:block;
  width:150px;
  height:auto;
  text-decoration:none;
  cursor:pointer;
}

首先我们清除一下元素默认的边距(内边距和外边距)和设置img的默认边框为0:

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

我们定义下ul的样式,包括ul的预设标记,大小,高度,边框:

ul {
  list-style-type:none;
  background: transparent url(/articleimg/2007/03/4514/map_flat.jpg) no-repeat 0 0;
  width:350px;
  height:250px;
  border:1px solid #000;
}

对于li的显示方式设置内联(display: inline;)行布局

ul li {
  display:inline;
}

下面是我们讲解的重点,隐藏/显示效果。

对li中的a元素我们设置其块元素显示(display: block;),让其相对位置(position: relative;),并使链接不显示下划线。

ul li a {
  position:relative;
  display:block;
  text-decoration:none;
}

让类选择器为offset的span隐藏,至于怎样隐藏文章开头已经分析了:

ul li a span.offset {
  position:absolute;
  margin-top:-9000px;
  margin-left:-9000px;
}

如上已经实现了内容隐藏,现在我们制作考虑触发显示的效果:

ul li a:hover span.offset, ul li a:focus span.offset, ul li a:active span.offset {
  color: #000;
  background-image:none;
  background-color:#ffffde;
  border:1px solid #000;
  display:block;
  width:150px;
  height:auto;
  text-decoration:none;
  cursor:pointer;
}

 

首先我们清除一下元素默认的边距(内边距和外边距)和设置img的默认边框为0:

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

我们定义下ul的样式,包括ul的预设标记,大小,高度,边框:

ul {
  list-style-type:none;
  background: transparent url(/articleimg/2007/03/4514/map_flat.jpg) no-repeat 0 0;
  width:350px;
  height:250px;
  border:1px solid #000;
}

对于li的显示方式设置内联(display: inline;)行布局

ul li {
  display:inline;
}

下面是我们讲解的重点,隐藏/显示效果。

对li中的a元素我们设置其块元素显示(display: block;),让其相对位置(position: relative;),并使链接不显示下划线。

ul li a {
  position:relative;
  display:block;
  text-decoration:none;
}

让类选择器为offset的span隐藏,至于怎样隐藏文章开头已经分析了:

ul li a span.offset {
  position:absolute;
  margin-top:-9000px;
  margin-left:-9000px;
}

如上已经实现了内容隐藏,现在我们制作考虑触发显示的效果:

ul li a:hover span.offset, ul li a:focus span.offset, ul li a:active span.offset {
  color: #000;
  background-image:none;
  background-color:#ffffde;
  border:1px solid #000;
  display:block;
  width:150px;
  height:auto;
  text-decoration:none;
  cursor:pointer;
}

 

首先我们清除一下元素默认的边距(内边距和外边距)和设置img的默认边框为0:

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

我们定义下ul的样式,包括ul的预设标记,大小,高度,边框:

ul {
  list-style-type:none;
  background: transparent url(/articleimg/2007/03/4514/map_flat.jpg) no-repeat 0 0;
  width:350px;
  height:250px;
  border:1px solid #000;
}

对于li的显示方式设置内联(display: inline;)行布局

ul li {
  display:inline;
}

下面是我们讲解的重点,隐藏/显示效果。

对li中的a元素我们设置其块元素显示(display: block;),让其相对位置(position: relative;),并使链接不显示下划线。

ul li a {
  position:relative;
  display:block;
  text-decoration:none;
}

让类选择器为offset的span隐藏,至于怎样隐藏文章开头已经分析了:

ul li a span.offset {
  position:absolute;
  margin-top:-9000px;
  margin-left:-9000px;
}

如上已经实现了内容隐藏,现在我们制作考虑触发显示的效果:

ul li a:hover span.offset, ul li a:focus span.offset, ul li a:active span.offset {
  color: #000;
  background-image:none;
  background-color:#ffffde;
  border:1px solid #000;
  display:block;
  width:150px;
  height:auto;
  text-decoration:none;
  cursor:pointer;
}

 

首先我们清除一下元素默认的边距(内边距和外边距)和设置img的默认边框为0:

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

我们定义下ul的样式,包括ul的预设标记,大小,高度,边框:

ul {
  list-style-type:none;
  background: transparent url(/articleimg/2007/03/4514/map_flat.jpg) no-repeat 0 0;
  width:350px;
  height:250px;
  border:1px solid #000;
}

对于li的显示方式设置内联(display: inline;)行布局

ul li {
  display:inline;
}

下面是我们讲解的重点,隐藏/显示效果。

对li中的a元素我们设置其块元素显示(display: block;),让其相对位置(position: relative;),并使链接不显示下划线。

ul li a {
  position:relative;
  display:block;
  text-decoration:none;
}

让类选择器为offset的span隐藏,至于怎样隐藏文章开头已经分析了:

ul li a span.offset {
  position:absolute;
  margin-top:-9000px;
  margin-left:-9000px;
}

如上已经实现了内容隐藏,现在我们制作考虑触发显示的效果:

ul li a:hover span.offset, ul li a:focus span.offset, ul li a:active span.offset {
  color: #000;
  background-image:none;
  background-color:#ffffde;
  border:1px solid #000;
  display:block;
  width:150px;
  height:auto;
  text-decoration:none;
  cursor:pointer;
}

 

首先我们清除一下元素默认的边距(内边距和外边距)和设置img的默认边框为0:

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

 

* {
   margin:0;
   padding:0;
}

img {
   border:0;
}

我们定义下ul的样式,包括ul的预设标记,大小,高度,边框:

ul {
  list-style-type:none;
  background: transparent url(/articleimg/2007/03/4514/map_flat.jpg) no-repeat 0 0;
  width:350px;
  height:250px;
  border:1px solid #000;
}

对于li的显示方式设置内联(display: inline;)行布局

ul li {
  display:inline;
}

下面是我们讲解的重点,隐藏/显示效果。

对li中的a元素我们设置其块元素显示(display: block;),让其相对位置(position: relative;),并使链接不显示下划线。

ul li a {
  position:relative;
  display:block;
  text-decoration:none;
}

让类选择器为offset的span隐藏,至于怎样隐藏文章开头已经分析了:

ul li a span.offset {
  position:absolute;
  margin-top:-9000px;
  margin-left:-9000px;
}

如上已经实现了内容隐藏,现在我们制作考虑触发显示的效果:

ul li a:hover span.offset, ul li a:focus span.offset, ul li a:active span.offset {
  color: #000;
  background-image:none;
  background-color:#ffffde;
  border:1px solid #000;
  display:block;
  width:150px;
  height:auto;
  text-decoration:none;
  cursor:pointer;
}

9 7 3 1 2 3 4 4 8 :

  把此文章收藏到:          
广而告之
文章搜索
  • Google JZxue.Com

关于我们 | 联系我们 | 友情链接 | 网站地图
Copyright © 2005 - 2006 建站学 All rights reserved.