提前感谢一堆!
我能够使用CSS制作圆角按钮。我喜欢能够鼠标悬停按钮,整个事物改变它的颜色,而不仅仅是最内在的div。请帮忙!
我的假设是我应该在onmouseover =“”上有一些javascript,对吗?
这是页面:http://biozenconsulting.com/new/
(另外,在IE8和Chrome浏览器中查看时,如何摆脱右角出现的小盒子?)
这是HTML代码:
<div class="nav_menu" onclick="location.href='index.htm'">
<b class="top_menu"><b class="top_menu1"><b></b></b><b class="top_menu2"><b></b></b><b class="top_menu3"></b><b class="top_menu4"></b><b class="top_menu5"></b></b>
<div class="top_menufg">
<!-- content goes here -->
Home
</div>
<b class="top_menu"><b class="top_menu5"></b><b class="top_menu4"></b><b class="top_menu3"></b><b class="top_menu2"><b></b></b><b class="top_menu1"><b></b></b></b>
</div>
这是CSS:
.nav_menu {
text-align: center;
color: #353535;
font-size: 20pt;
font-family: Verdana, Geneva, sans-serif;
float: left;
width: 33%;
}
#about {
margin: 0 .5% 0 .5%;
}
<!-- For rounded boxes -->
.top_menu {
display:block
overflow: hidden;
}
.top_menu *{
display:block;
height:1px;
overflow:hidden;
font-size:.01em;
background:#AAAAAA
}
.top_menu1{
margin-left:3px;
margin-right:3px;
padding-left:1px;
padding-right:1px;
border-left:1px solid #AAAAAA;
border-right:1px solid #AAAAAA;
background:#AAAAAA
}
.top_menu2{
margin-left:1px;
margin-right:1px;
padding-right:1px;
padding-left:1px;
border-left:1px solid #AAAAAA;
border-right:1px solid #AAAAAA;
background:#AAAAAA
}
.top_menu3{
margin-left:1px;
margin-right:1px;
border-left:1px solid #AAAAAA;
border-right:1px solid #AAAAAA;
}
.top_menu4{
border-left:1px solid #AAAAAA;
border-right:1px solid #AAAAAA
}
.top_menu5{
border-left:1px solid #AAAAAA;
border-right:1px solid #AAAAAA
}
.top_menufg{
background:#AAAAAA
}
.top_menufg:hover{
background-color: #888888;
cursor: pointer;
}
<!-- For rounded boxes -->
答案 0 :(得分:2)
Stu Nicholls的网站css play有很多关于如何在没有javascript的情况下执行此操作的示例。这是一个非常好的资源。
答案 1 :(得分:0)
我用链接替换了外部div并添加了一点CSS。
HTML
<a class="nav_menu" href="index.htm">
<b class="top_menu"><b class="top_menu1"><b></b></b><b class="top_menu2"><b></b></b><b class="top_menu3"></b><b class="top_menu4"></b><b class="top_menu5"></b></b>
<div class="top_menufg">
<!-- content goes here -->
Home
</div>
<b class="top_menu"><b class="top_menu5"></b><b class="top_menu4"></b><b class="top_menu3"></b><b class="top_menu2"><b></b></b><b class="top_menu1"><b></b></b></b>
</a>
CSS
.nav_menu {
text-align: center;
color: #353535;
font-size: 20pt;
font-family: Verdana, Geneva, sans-serif;
float: left;
width: 33%;
text-decoration: none;
}
/* For rounded boxes */
.top_menu {
display:block
overflow: hidden;
}
.top_menu * {
display:block;
height:1px;
overflow:hidden;
font-size:.01em;
background:#AAAAAA
}
.top_menu1 {
margin-left:3px;
margin-right:3px;
padding-left:1px;
padding-right:1px;
border-left:1px solid #AAAAAA;
border-right:1px solid #AAAAAA;
background:#AAAAAA
}
.top_menu2 {
margin-left:1px;
margin-right:1px;
padding-right:1px;
padding-left:1px;
border-left:1px solid #AAAAAA;
border-right:1px solid #AAAAAA;
background:#AAAAAA
}
.top_menu3 {
margin-left:1px;
margin-right:1px;
border-left:1px solid #AAAAAA;
border-right:1px solid #AAAAAA;
}
.top_menu4 {
border-left:1px solid #AAAAAA;
border-right:1px solid #AAAAAA
}
.top_menu5 {
border-left:1px solid #AAAAAA;
border-right:1px solid #AAAAAA
}
.top_menufg {
background:#AAAAAA
}
a.nav_menu:hover b, a.nav_menu:hover div {
background-color: #888888;
cursor: pointer;
}
/* For rounded boxes */