简体   繁体   English

使asp.net按钮控件的角变圆

[英]Make the corners of asp.net Button Control Rounded

In my custom webpart I am using few buttons and would like to make their corners rounded. 在我的自定义Webpart中,我使用了几个按钮,希望使它们的角变圆。

Below is one of my button in the ascx file: 以下是我在ascx文件中的按钮之一:

 <style type="text/css">
   {
   .BtnStyle
   {
    border: thin ridge #FF0000; 
    background-color: #C0C0C0; 
    font-family: verdana; 
    font-size: 8pt; 
    font-weight: bold; 
    color: #FF0000;
    border-top-left-radius: 10px 5px; --- did not work 
    border-bottom-right-radius: 10% 5%; --did not work 
    border-top-right-radius: 10px; -- did not work 
    -moz-border-radius: 15px; --- did not work 
    -webkit-border-radius: 15px; --- did not work 
    border-radius: 15px; --- did not work and gives an error saying not a valid CSS property

}
}

<table width="500px">
<tr>
<td align="right"  >
<table width="60%">
<tr>
    <td  valign="middle" align="right">
        <asp:Button ID="bttn1" runat="server" onclick="bttn1_Click" 
            Text="Delete" CssClass="BtnStyle" />
    </td>

Nothing worked. 没事。 Please provide me CSS code that helps me making the corners rounded. 请向我提供CSS代码,以帮助我弄圆角。

The correct property should be: 正确的属性应为:

border-radius:15px;

You can drop the vendor prefixes, as all modern browsers accepts the standard now anyway. 您可以删除供应商前缀,因为所有现代浏览器现在都接受该标准。 I don't know why it doesn't work in your case, but I would check the output to see if the class is there or the style is dropped. 我不知道为什么在您的情况下不起作用,但是我将检查输出以查看类是否存在或样式是否已删除。

Your editor doesn't recognize CSS3 properties, which is why it's marked as invalid. 您的编辑器无法识别CSS3属性,因此将其标记为无效。 That doesn't mean it's actually invalid, as modern browsers will parse it just fine. 这并不意味着它实际上是无效的,因为现代浏览器会对其进行解析。

Also bear in mind that any IE version below 9 doesn't support border-radius. 还请记住,任何低于9的IE版本都不支持边界半径。 You can use http://css3pie.com/ to make IE7 and IE8 support it, but I think it's better to leave it out and reserve the fancy stuff for the modern browsers, unless the client demands it. 您可以使用http://css3pie.com/来使IE7和IE8支持它,但是我认为最好不要使用它,并为现代浏览器保留一些花哨的东西,除非客户要求。

EDIT: You have too many curly brackets. 编辑:您有太多花括号。 Remove the first and last one. 删除第一个和最后一个。 Also, your style tag is not closed. 此外,您的样式标签未关闭。

Which browser are you using? 您正在使用哪个浏览器? Border-radius is not supported on IE versions before ie9 as this tag is considered an advanced CSS property. ie9之前的IE版本不支持边界半径,因为该标记被视为高级CSS属性。

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

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