Fork me on GitHub
魔芋铃

中国地图

中国地图Div+CSS



1. 设置省会城市的margin值。
2. 然后,有些城市离得很近,要修改图标和文字的左右位置。
3. 最后设置:CSS中绝对定位将图标放在合适的位置。

完整代码demo:http://yun.baidu.com/s/1pJvDnK3

效果图:

HTML代码



中国地图div+css版





CSS代码

html ,body,h1,div{ padding:0;margin:0;font-size: 12px; }

body {
background: #fff;line-height: 1.8; font-family: verdana, "宋体", arial,sans;
}

main {

margin: 10px auto 0; width: 950px; text-align: left;
}

map {

background: url(map.gif) no-repeat left top; float: left; width: 552px; height: 447px;
}

map h1 {

font-weight: normal; position: absolute;
}

a:link, a:visited {
display: block; background: url(maph1.gif) no-repeat; color: #000; text-decoration: none;
}

.mapl a:link {
background-position: left 4px; padding-left: 20px;
}

.mapr a:link {
background-position: right 4px;padding-right: 20px;
}

.mapl a:hover, .mapr a:hover {
padding-right: 20px; display: block; background: url(maph1.gif) no-repeat; color: #ff0000
}

.mapr a:hover {
background-position: right bottom;padding-right: 20px;
}
.mapl a:hover {
background-position: left bottom; padding-left: 20px
}

posted @ 2015-06-12 00:54  魔芋铃  阅读(500)  评论(0)    收藏  举报