【问题标题】:Does not work border-radius IE8不工作边界半径 IE8
【发布时间】:2012-06-09 13:40:06
【问题描述】:

为了在 IE8 中实现边框半径,我使用 border-radius.htc

realzovat border-radius 正常工作的块:

.mc-button
{
    -moz-transition: all 0.218s ease 0s;
    -moz-user-select: none;
    background-color: #CBCBCB;
    background-image: -moz-linear-gradient(center top , #CBCBCB, #DCDCDC);
    border: 1px solid #DCDCDC;
    color: #FFFFFF;
    cursor: default;
    display: inline-block;
    font-size: 11px;
    font-weight: bold;
    height: 29px;
    line-height: 29px;
    min-width: 70px;
    padding: 0 8px !important;
    text-align: center;
    overflow: visible;
    font-family: inherit;
    font-size: inherit;
    float: left;
    text-decoration: none;
    display: block;
    -webkit-border-radius: 5px;
    -khtml-border-radius: 5px;
    -moz-outline-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    font-family: Arial, Sans-Serif !important;
    behavior:url(Content/border-radius.htc);
}

根据附件列表-border-radius.htc连接到页面

你能告诉我如何解决这个问题吗?

更新(2012 年 6 月 13 日)

如果代码被按钮替换:

.mc-button
{
    border: 1px solid #696;
    height: 29px;
    line-height: 29px;
    min-width: 70px;
    text-align: center;
    padding: 0 8px !important;
    overflow: visible;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    float: left;
    display: block;
    background: #00ADEE;
    background: -webkit-gradient(linear, 0 0, 0 bottom, from(#00ADEE), to(#0078A5));
    background: -webkit-linear-gradient(#00ADEE, #0078A5);
    background: -moz-linear-gradient(#00ADEE, #0078A5);
    background: -ms-linear-gradient(#00ADEE, #0078A5);
    background: -o-linear-gradient(#00ADEE, #0078A5);
    background: linear-gradient(#00ADEE, #0078A5);
    -pie-background: linear-gradient(#00ADEE, #0078A5);
    behavior: url("Content/PIE.htc");
}

并声明为:

<a id="login_button" class="mc-button mc-button-submit ">SomeText</a>

.mc-button-submit
{
    border: 0px solid #0076A3;
    background: #00ADEE;
    background: -webkit-gradient(linear, 0 0, 0 bottom, from(#00ADEE), to(#0078A5));
    background: -webkit-linear-gradient(#00ADEE, #0078A5);
    background: -moz-linear-gradient(#00ADEE, #0078A5);
    background: -ms-linear-gradient(#00ADEE, #0078A5);
    background: -o-linear-gradient(#00ADEE, #0078A5);
    background: linear-gradient(#00ADEE, #0078A5);
    -pie-background: linear-gradient(#00ADEE, #0078A5);
    color: #FFFFFF;
    text-align: center;
}

四舍五入就消失了。添加到 .mc-button-submit 行 behavior: url ("Content / PIE.htc"); 没有帮助。

你能告诉我如何连接第二个类和背景的参数吗?

【问题讨论】:

  • 您是否下载并安装了.htc 文件?
  • 如果我理解正确,它没有安装,只需使用连接:behavior:url(border-radius.htc);
  • 使用css3please.com 用于css3 功能的正确和跨浏览器语法,gradient generator 用于制作跨浏览器渐变
  • 我改进了您的样式并提供了应该可行的示例
  • 以下任何答案是否解决了您的问题?

标签: html internet-explorer-8 css


【解决方案1】:

独立的 .htc hack 不能同时用于后台 gradient 和 border-radius。

尝试用简单的图像替换 css gradient。这个技巧会奏效。

你也可以使用css3pie(感谢@dop-trois)——这个纯Javascript工具比独立的.htc文件更完美。

PS。插图box-shadows 无法在两种解决方案中实现。

PPS:您需要的代码在这里:(我对其进行了一些更改以使其更有效和正确):

.mc-button {
    font: bold 11px/29px Arial, Helvetica, sans-serif !important;
    text-align: center;
    text-decoration: none;
    color: #FFFFFF;

    border: 1px solid #DCDCDC;
    height: 29px;
    min-width: 70px;
    padding: 0 8px !important;
    overflow: visible;
    display: block;

    float: left;

    /* Unique link for this gradient — http://www.colorzilla.com/gradient-editor/#cbcbcb+0,dcdcdc+100;Custom */
    background-color: #CBCBCB;
    background: -moz-linear-gradient(top,  rgba(203,203,203,1) 0%, rgba(220,220,220,1) 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(203,203,203,1)), color-stop(100%,rgba(220,220,220,1))); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top,  rgba(203,203,203,1) 0%,rgba(220,220,220,1) 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top,  rgba(203,203,203,1) 0%,rgba(220,220,220,1) 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top,  rgba(203,203,203,1) 0%,rgba(220,220,220,1) 100%); /* IE10+ */
    background: linear-gradient(top,  rgba(203,203,203,1) 0%,rgba(220,220,220,1) 100%); /* W3C */

    /* css3 stuff below: (via css3please.com) */
    /* no one prefix except `-webkit` is needed nowadays for `border-radius` */
    -webkit-border-radius: 5px;
            border-radius: 5px;
    -webkit-transition: all 0.218s ease-out;
       -moz-transition: all 0.218s ease-out;
        -ms-transition: all 0.218s ease-out;
         -o-transition: all 0.218s ease-out;
            transition: all 0.218s ease-out;

    /* PIE specific accordingly http://css3pie.com/documentation/q-and-a/ */
    behavior: url(PIE.htc);
}

你应该确保你正确地包含了PIE.htc(重要!)

相关问题

根据答案可能的问题可能是mime类型(“text/x-component”)。

也可能的解决方案是:

position: relative;
z-index: 0;

【讨论】:

  • 在 IE9 中删除并添加渐变黑色背景后 - 有第二个圆角块,然后是背景 propaadet。在 IE8 中 - 背景不可见时的块
  • 以前,我无法回答。谢谢你的例子。我将 PIE.htc 文件连接到项目中。使用 F12 -> Network 已验证文件连接正确。替换为您自己的代码 - 角不是圆角。
  • @SomeName 我可以看看你的例子吗?
  • 删除了额外的类,这是一个按钮的渐变 - 它有效,谢谢)
  • @Vladimir Starkov 唯一的,请看,第一篇文章中的更新)
【解决方案2】:

要应用渐变和边框半径,我推荐 CSS3 Pie。这是我所知道的最强大的工具,可以在 IE 中应用 CSS3 属性。

在 IE 中应用渐变):

#myElement {
    background: #CCC; /*fallback for non-CSS3 browsers*/
    background: -webkit-gradient(linear, 0 0, 0 100%, from(#CCC) to(#EEE)); /*old webkit*/
    background: -webkit-linear-gradient(#CCC, #EEE); /*new webkit*/
    background: -moz-linear-gradient(#CCC, #EEE); /*gecko*/
    background: -ms-linear-gradient(#CCC, #EEE); /*IE10*/
    background: -o-linear-gradient(#CCC, #EEE); /*opera 11.10+*/
    background: linear-gradient(#CCC, #EEE); /*future CSS3 browsers*/
    -pie-background: linear-gradient(#CCC, #EEE); /*PIE*/
    behavior: url(PIE.htc);
}​

在 IE 中应用边框半径):

#myAwesomeElement {
    border: 1px solid #999;
    -webkit-border-radius: 10px;
    -moz-border-radius: 10px;
    border-radius: 10px;
    behavior: url(path/to/PIE.htc);
}​

你需要 PHP 才能让它工作。

Live demo 在 CSS3 Pie 的网站上。

顺便说一句:使用此工具可以同时应用边框半径和渐变 ;)

希望这会有所帮助:)

【讨论】:

  • 仅适用于 PIE 而不是独立的.htc
  • 正确,就像我在回答中指出的那样“你需要 PHP 才能让它工作。”
  • 谢谢,但是项目中没有使用 PHP。
  • .HTC 文件是纯javascript文件,不需要PHP支持
  • @dop-trois php 文件包含在 PIE 中,前提是您希望在服务器上预处理您的 css
【解决方案3】:

要应用渐变、框阴影和边框半径,我推荐 CSS3 Pie。我在 cook&smile 项目中使用它,它在 IE 中完全可以工作。

*{ behavior:url(path/PIE.htc);}

.border_radius_div{ position:relative; -webkit-border-radius: 10px; -moz-border-radius: 10px;  border-radius: 10px;}

.gradient_div{ position:relative; 
background: #EEFF99;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#EEFF99), to(#66EE33));
background: -webkit-linear-gradient(#EEFF99, #66EE33);
background: -moz-linear-gradient(#EEFF99, #66EE33);
background: -ms-linear-gradient(#EEFF99, #66EE33);
background: -o-linear-gradient(#EEFF99, #66EE33);
background: linear-gradient(#EEFF99, #66EE33);
-pie-background: linear-gradient(#EEFF99, #66EE33); }

访问此网站以进一步探索自己。

http://css3pie.com

注意:

  1. 不要忘记在我们使用边框半径、渐变和框阴影的地方使用位置(相对或绝对)。

  2. 别忘了使用behavior:url(xhtml_folder/PIE.htc);

  3. 重要的是不要忘记将 PIE.htc 放在 xhtml 文件夹中。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-15
    • 1970-01-01
    • 2013-02-07
    • 1970-01-01
    • 2014-04-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多