首先我们来编写基本的HTML结构
给LI元素添加一个active类,标识鼠标响应的样式,给大的div添加一个popover类,便于我们查找到这个元素。
接下来我们来看看CSS样式是怎样的。
首先我们给div添加一点效果
.popover {
position: relative;
padding: 5px;
background: #606060;
border: 1px solid black;
border-radius: 11px;
background-image: -webkit-linear-gradient(top, #606060, #4a4a4a);
background-image: -moz-linear-gradient(top, #606060, #4a4a4a);
background-image: -o-linear-gradient(top, #606060, #4a4a4a);
background-image: linear-gradient(to bottom, #606060, #4a4a4a);
-webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 1px rgba(255, 255, 255, 0.2), inset 1px 0 rgba(255, 255, 255, 0.08), inset -1px 0 rgba(255, 255, 255, 0.08), 0 2px 8px rgba(0, 0, 0, 0.5);
box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 1px rgba(255, 255, 255, 0.2), inset 1px 0 rgba(255, 255, 255, 0.08), inset -1px 0 rgba(255, 255, 255, 0.08), 0 2px 8px rgba(0, 0, 0, 0.5);
}
上面的代码中,我们给div设置一个内阴影和渐变背景,这都要归功于CSS3先进的属性,不然这些效果就只能使用背景图片
然后我们定义UL的样式
.popover ul {
overflow: hidden;
background: white;
border: 1px solid black;
border-radius: 7px;
-webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 1px rgba(255, 255, 255, 0.1), 0 1px rgba(255, 255, 255, 0.1);
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 1px rgba(255, 255, 255, 0.1), 0 1px rgba(255, 255, 255, 0.1);
}
这样看起来,div和ul之间就有了一点间隙,从视觉上看就是有了边框
然后我们添加那个三角形效果
.popover:before, .popover:after, .popover ul:before {
content: '';
display: block;
position: absolute;
left: 22px;
width: 0;
height: 0;
border: 7px outset transparent;
}
.popover:before {
top: -14px;
border-bottom: 7px solid black;
}
.popover:after {
top: -13px;
border-bottom: 7px solid #888;
}
.popover ul:before {
z-index: 2;
top: -12px;
border-bottom: 8px solid #666;
}
设置LI样式
.popover li {
display: block;
}
.popover li + li {
border-top: 1px solid #eee;
}
.popover li:first-child a {
border-radius: 7px 7px 0 0;
}
.popover li:last-child a {
border-radius: 0 0 7px 7px;
}
定义A链接元素鼠标响应样式
.popover a {
display: block;
position: relative;
line-
padding: 0 15px 0 48px;
font-size: 16px;
font-weight: bold;
color: black;
text-decoration: none;
}
.popover a:hover {
background: white;
-webkit-box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}
好了以上就是这个效果的核心代码,有一些代码在这里没有列出来,比如清空浏览器默认给元素的样式值等。
茶杯头甜蜜终章dlc 官方手机版v1.0.0.3
下载火柴人传说暗影格斗内置菜单 最新版v3.0.1
下载荒野乱斗测试服 安卓版v61.10.3
下载荒野乱斗彩虹服 安卓版v61.10.3
下载寒霜启示录 安卓版v1.25.10
寒霜启示录是一款生存模拟游戏,不少玩家可能对于末日都有着自己
末日城堡免广告版 安卓最新版v0.7.1
末日城堡免广告版是一款非常好玩的模拟经营类游戏,内部可以不看
甜蜜人生模拟器 最新版v1.4.5
甜蜜人生模拟器是一款非常好玩的模拟恋爱手游,玩家在这里能够对
武器锻造师内置功能菜单 v10.4
武器锻造师内置菜单版是游戏的破解版本,在该版本中为玩家提供了
开放空间overfield 安卓版v1.0.5
开放空间Overfield是一款箱庭养成经营手游,让你在广阔