<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:
* { img { * { img { * { img { * { img { * { img { * { img { 我们定义下ul的样式,包括ul的预设标记,大小,高度,边框:
ul { 对于li的显示方式设置内联(display: inline;)行布局:
ul li { 下面是我们讲解的重点,隐藏/显示效果。 对li中的a元素我们设置其块元素显示(display: block;),让其相对位置(position: relative;),并使链接不显示下划线。
ul li a { 让类选择器为offset的span隐藏,至于怎样隐藏文章开头已经分析了:
ul li a span.offset { 如上已经实现了内容隐藏,现在我们制作考虑触发显示的效果:
ul li a:hover span.offset, ul li a:focus span.offset, ul li a:active span.offset {
margin:0;
padding:0;
}
border:0;
}
margin:0;
padding:0;
}
border:0;
}
margin:0;
padding:0;
}
border:0;
}
margin:0;
padding:0;
}
border:0;
}
margin:0;
padding:0;
}
border:0;
}
margin:0;
padding:0;
}
border:0;
}
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;
}
display:inline;
}
position:relative;
display:block;
text-decoration:none;
}
position:absolute;
margin-top:-9000px;
margin-left:-9000px;
}
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:
* { img {
margin:0;
padding:0;
}
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:
* { img {
margin:0;
padding:0;
}
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:
* { img {
margin:0;
padding:0;
}
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:
* { img {
margin:0;
padding:0;
}
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:
* { img {
margin:0;
padding:0;
}
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;
}