【问题标题】:top rounded corners in my jquery我的jQuery中的顶部圆角
【发布时间】:2010-04-22 17:45:45
【问题描述】:

我的菜单按钮有这个 jquery,我想要的是为我的菜单设置顶角,这是一个完整的代码:

    <html>
<style type="text/css">
#menuBarHolder { width: 860px; height:45px; background-color:#000; color:#fff; font-family:Arial; font-size:14px; margin-top:20px;}
#menuBarHolder ul{ list-style-type:none; display:block;}
.firstchild { border-left:1px solid #ccc;}
#container { margin-top:10px;}
#menuBar li{  float:left;  padding:15px; height:16px; width:70px; border-right:1px solid #ccc; }
#menuBar li a{color:#fff; text-decoration:none; letter-spacing:-1px; font-weight:bold;}
.menuHover { background-color:#999;}
.menuInfo { cursor:hand; background-color:#000; color:#fff; width:74px; font-size:11px;height:100px; padding:3px; display:none;  position:absolute; margin-left:-15px; margin-top:0px;
-moz-border-radius-bottomright: 5px; -moz-border-radius-bottomleft: 5px;
    -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px;
    -khtml-border-radius-bottomright: 5px;   -khtml-border-radius-bottomleft: 5px;
    border-radius-bottomright: 5px;border-radius-bottomleft: 5px;
}

</style>

<!--[if IE]>
<style type="text/css">
#menuBar li a{width:50px;}
.menuInfo { margin-left:-65px; width:80px;}
</style>

<![endif]-->

<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.js"></script>
<script type="text/javascript">

$(document).ready(function()
{

$('#menuBar li').click(function()
{
  var url = $(this).find('a').attr('href');
  document.location.href = url;

});

$('#menuBar li').hover(function()
{

   $(this).find('.menuInfo').slideDown();
},
function()
{

  $(this).find('.menuInfo').slideUp();

});

});
</script>
<center>
<div id="menuBarHolder">
<ul id="menuBar">
<li class="firstchild"><a href="javascript:#">Home</a><div class="menuInfo">I am some text about the home section</div></li>
<li><a href="javascript:#">About Us</a><div class="menuInfo">I am some text about the services section</div></li>
<li><a href="javascript:#">News</a><div class="menuInfo">I am some text about the clients section</div></li>
<li><a href="javascript:#">Equipment</a><div class="menuInfo">I am some text about the portfolio section</div></li>
<li><a href="javascript:#">Services</a><div class="menuInfo">I am some text about the about section</div></li>
<li><a href="javascript:#">Project</a><div class="menuInfo">I am some text about the blog section</div></li>
<li><a href="javascript:#">Contact Us</a><div class="menuInfo">I am some text about the follow section</div></li>
</ul>
</div>
</div>
</center>
</html>

感谢您的帮助。

【问题讨论】:

    标签: javascript jquery css


    【解决方案1】:

    下面的 CSS3 代码应该可以做到:

    &lt;head&gt; 标签的主体内添加以下代码:

    <style type="text/css">
        -webkit-border-top-left-radius: 5px;
        -webkit-border-top-right-radius: 5px;
        -moz-border-radius-topleft: 5px;
        -moz-border-radius-topright: 5px;
        border-top-left-radius: 5px;
        border-top-right-radius: 5px;
    </style>
    

    但请注意,目前只有现代浏览器支持 CSS3

    注意:对于跨浏览器解决方案,您可以使用:

    JQuery Curvy Corners Plugin

    所以如果你真的想要弯曲的角落,我建议你使用 JQuery Curvy Corners Plugin。

    很棒的资源:

    在这里创建自己的角落:

    http://border-radius.com/

    【讨论】:

    • @Sohail,CSS 要么放在 css 样式表 #element_needing_rounded_corners {/* css3 stuff */} 中,要么放在 html 页面的 &lt;head&gt; 中的 &lt;style&gt; 标签内。
    【解决方案2】:

    根据您上面的 CSS,您只是指定左下角和右下角应该是圆角的。

    如果你想要左上角和右上角圆角而不是更改:

    -moz-border-radius-bottomright: 5px; 
    -moz-border-radius-bottomleft: 5px;
    -webkit-border-bottom-left-radius: 5px;
    -webkit-border-bottom-right-radius: 5px;
    

    -moz-border-radius-topright: 5px; 
    -moz-border-radius-topleft: 5px;
    -webkit-border-top-left-radius: 5px;
    -webkit-border-top-right-radius: 5px;
    

    如果您希望所有四个角都变圆,只需:

    -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
    

    【讨论】:

      【解决方案3】:

      试试看jquery UI,它也有主题,

      如果我想让我的所有 div 内容走投无路,我就这样做,

      <div class="ui-wiget-content ui-corner-all">bla bla</div>
      

      他们刚刚完成了所有课程设置。

      你可以检查他们的css文件来了解他们是如何做到的,但是它对IE不起作用,呵呵。

      【讨论】:

        猜你喜欢
        • 2014-10-20
        • 2023-04-01
        • 1970-01-01
        • 2012-05-06
        • 2020-11-29
        • 1970-01-01
        • 2011-11-09
        • 2016-09-06
        • 2018-02-21
        相关资源
        最近更新 更多