简体   繁体   English

html页面中的div样式

[英]div styles in html page

All, 所有,

How to make the div more presentable in the below code. 如何在下面的代码中使div更具表现力。 ie, on mouseover the div should look like as same as title attribute or even better And the text on it should also look presentable 即,在鼠标悬停时,div应该看起来与title属性相同,甚至更好,并且其上的文本也应该看起来像样。

 <style type="text/css">
 #div1 { width: 200px; height: 30px; background-color: #a9a9a9; color: #fff; position: absolute; }
</style>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
 $(window).mouseover(function(event){
    $("#div1").css({'top': event.pageY, 'left': event.pageX});  
});
});
</script>
<div id="div1">move me</div>

Thanks..... 谢谢.....

How about this: 这个怎么样:

<style type="text/css">
 #div1 {
 font-size: 12px;
 font-family: helvetica;
 background-color: #ffffaa;
 color: black;
 position: absolute;
 border-left: solid 1px #d0d0d0;
 border-top: solid 1px #d0d0d0;
 border-right: solid 1px #a0a0a0;
 border-bottom: solid 1px #a0a0a0;
 padding: 1px;
}
</style>

It looks a bit like the title tool tip (but be aware, that every user can have a different configuration via OS or browser) and it adds a light 3d effect. 它看起来有点像标题工具提示(但请注意,每个用户都可以通过OS或浏览器进行不同的配置),并且添加了明亮的3d效果。 If you are using CSS3, you can also use gradients, round corners and shadows, which can look nice. 如果您使用的是CSS3,则还可以使用渐变,圆角和阴影,看起来不错。

How about this: 这个怎么样:

$(function(){
 $(window).mouseover(function(event){
    $("#div1").css({'color': '#0000ff'});
    $("#div1").css({'font-weight': 'bold'});
    $("#div1").css({'background-color': '#00ff00'});
});
});

I think you should switch from "mouseover" to "mousemove", because it's a bit of a smoother effect: 我认为您应该从“ mouseover”切换到“ mousemove”,因为这样的效果会更平滑一些:

$(window).mousemove(function(event){
    $("#div1").css({'top': event.pageY, 'left': event.pageX});  
});

As for the look, here's the Windows tooltip look (if that's what you wanted): 至于外观,这是Windows工具提示的外观(如果您要这样做的话):

<style type="text/css">
    #div1
    {
        color: #000;
        background: #FDFFC9;
        border: 1px solid #000;
        font: 12px Arial, sans-serif;
        padding: 5px;
        position: absolute;
    }
</style>

And here's something you might like: 这是您可能会喜欢的东西:

<style type="text/css">
    #div1
    {
        color: #FFF;
        background: #5289BF;
        border: 1px solid #369;
        border-width: 0 2px 2px 0;
        font: bold 15px Arial, serif;
        padding: 10px;
        position: absolute;
    }
</style>

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

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