简体   繁体   English

用javascript和CSS制作信息框

[英]Make in formation boxes with javascript and CSS

I would like to make information boxes like this one: 我想制作这样的信息框:

http://mmarfil.com/ [mouseover to see] http://mmarfil.com/ [鼠标悬停即可查看]

That particular site uses jQuery fadeIn and fadeOut to show an image (an actual png) of the tooltip like this: 该特定站点使用jQuery fadeIn和fadeOut来显示工具提示的图像(实际png),如下所示:

$('.toggle').hover(
        function(){
            $('#baloon').fadeIn('normal');
        }, function() {
            $('#baloon').fadeOut('normal');
});

The image is positioned above the box using the css fixed positioning: 使用css固定位置将图像放置在框的上方:

position: fixed;
margin-left: X px;
margin-top: Y px;

Similar results can be achieved using html, positioning a div instead of an image. 使用html定位div而不是图像可以实现类似的结果。

You only need CSS for that... 您只需要CSS ...

CSS: CSS:

a:link,
a:visited {
position:relative;
text-decoration:none;
}

a .tooltip img {
border:none;
}

.tooltip {
width:300px;
position:absolute;
bottom:100%;
margin:0 0 7px 0;
padding:15px;
font-family:Verdana,sans-serif;
font-size:15px;
font-weight:normal;
font-style:normal;
text-align:left;
text-decoration:none;
text-shadow:0 1px 0 rgba(255,255,255,0.3);
line-height:1.5;
border:solid 1px;
-moz-border-radius:7px;
-webkit-border-radius:7px;
border-radius:7px;
-moz-box-shadow:
0 1px 2px rgba(0,0,0,0.3),
0 1px 2px rgba(255,255,255,0.5) inset;
-webkit-box-shadow:
0 1px 2px rgba(0,0,0,0.3),
0 1px 2px rgba(255,255,255,0.5) inset;
box-shadow:
0 1px 2px rgba(0,0,0,0.3),
0 1px 2px rgba(255,255,255,0.5) inset;
cursor:default;
display:block;
visibility:hidden;
opacity:0;
z-index:999;
-moz-transition:all 0.4s linear;
-webkit-transition:all 0.4s linear;
-o-transition:all 0.4s linear;
transition:all 0.4s linear;
}

.tooltip:before,
.tooltip:after {
width:0;
height:0;
position:absolute;
bottom:0;
margin:0 0 -20px -10px;
border:solid 10px;
border-color:transparent;
display:table-cell;
content:"";
}

.tooltip:before {
margin:0 0 -24px -12px;
border:solid 12px;
border-color:transparent;
z-index:-1;
}

/* hover */

a:hover .tooltip {
text-decoration:none;
visibility:visible;
opacity:1;
-moz-transition:all 0.2s linear;
-webkit-transition:all 0.2s linear;
-o-transition:all 0.2s linear;
transition:all 0.2s linear;
}

CSS color-scheme class: CSS颜色方案类:

.tooltip.green {
color:#445400;
background:#8DB600;
background:-moz-linear-gradient(top,rgba(141,182,0,0.8),rgba(141,182,0,1));
background:-webkit-gradient(linear,left top,left bottom,from(rgba(141,182,0,0.8)),to(rgba(141,182,0,1)));
border-color:#7C9902;
}

Usage: 用法:

<a href="#">bistre<span class="tooltip green">THIS IS A TOOOOOLTIPP!!!/span></a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM