简体   繁体   English

IE11中CSS圆角元素失败

[英]CSS rounded corner element fails in IE11

I'm basically trying to do a "CSS-triangle" (you know, an element where the entire shape is generated using borders) but instead of a triangle shape, I want a square with rounded corners on the left side and straight corners on the right side. 我基本上是想做一个“ CSS三角形”(您知道一个使用边框生成整个形状的元素),但我想使用一个正方形,而不是一个三角形,该正方形的左侧为圆角,而其上为直角右边。

This works fine in Chrome but IE11 creates a weird artefact at the top-left corner. 这在Chrome中可以正常工作,但IE11在左上角会产生一个奇怪的伪像。 (a background-colored oval right where the rounded corner should be. really strange!) (背景色的椭圆形右边应该是圆角。真的很奇怪!)

Is there a way to create a workaround for IE11? 有没有办法为IE11创建解决方法?

.RoundedElement {
  width: 0;
  height: 0;
  border-top: none;
  border-bottom: 50px solid transparent;
  border-right: 20px solid #00a2d4;
  position: relative;
  right: 20px;
  border-radius: 15px 0px 0px 15px;
 border-color: #F7A824;
}

http://codepen.io/anon/pen/QbjaOG http://codepen.io/anon/pen/QbjaOG

I think you are over complicating the problem here. 我认为您在这里使问题复杂化了。

Try the following: 请尝试以下操作:

 body { margin: 50px; } .RoundedElement { width: 30px; height: 50px; position: relative; right: 20px; border-radius: 15px 0px 0px 15px; background-color: #F7A824; } 
 <div class="RoundedElement"> </div> 

Why not use the regular background-color with border radius that works by default ? 为什么不使用默认情况下具有边框半径的常规background-color呢?

If you still want to use border try the following: 如果仍然要使用border尝试以下操作:

 body { margin: 50px; } .RoundedElement { width: 20px; //Added 20px to fix in FF. height: 0px; border-top:30px solid transparent; border-bottom: 30px solid transparent; border-right: 40px solid #00a2d4; position: relative; border-radius: 15px 0px 0px 15px; border-color: #F7A824; } 
 <div class="RoundedElement"> </div> 

tweaking the code to: 将代码调整为:

body { margin: 50px; }

.RoundedElement {
  width: 10px;
  height: 0;
  border-top:30px solid transparent;
  border-bottom: 30px solid transparent;
  border-right: 10px solid #00a2d4;
  position: relative;
  right: 20px;
  border-radius: 15px 0px 0px 15px;
  border-color: #F7A824;
  z-index:2
}

pen 钢笔

works in FF (should also in ie but not tested) 在FF中工作(也应在IE中但未经测试)

There is no need to do it like this. 不需要这样做。 Use border-radius (support here ). 使用border-radius在此处支持)。 Also what you have is not a square, this is. 另外,您所拥有的不是正方形,而是正方形。

 div { width: 100px; height: 100px; border-radius: 50% 0px 0px 50%; background: #000; } 
 <div></div> 

It not work because your div size is 0: width: 0; 它不起作用,因为您的div大小为0:width:0; height: 0; 高度:0;

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

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