- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是radial-gradient
的新手,我不知道这些多维数据集之间的背线或空格是什么?如何删除它们?
* {margin: 0; outline: 0; border: 0;}
.round {
background: radial-gradient(circle at 0 100%, rgba(204, 0, 0, 0) 70%, #c00 71%),
radial-gradient(circle at 100% 100%, rgba(204, 0, 0, 0) 70%, #c00 71%),
radial-gradient(circle at 100% 0, rgba(204, 0, 0, 0) 70%, #c00 71%),
radial-gradient(circle at 0 0, rgba(204, 0, 0, 0) 70%, #c00 71%);
background-position: bottom left, bottom right, top right, top left;
background-size: 50% 50%;
background-repeat: no-repeat;
width: 300px;
height: 300px;
padding: 10%;
transform: rotate(45deg);
}
p {
transform: rotate(-45deg);
width: 100px;
margin: 100px;
}
By using radial gradients, you can simulate rounded corners with a negative radius. Just in this case,
1 Câu trả lời
您的摘要中有两个问题,当我们修复中间出现的怪异间隙或线条时,这些问题将完全消失。
问题1:您正在元素上设置padding: 10%
而不是固定值。当我们以百分比形式给出值时,就四舍五入逻辑而言,我们受制于UA。每个UA都有自己的四舍五入逻辑。例如,框的包含块的宽度为510px
,现在51px
为10%。元素的实际宽度包括其填充,因此此处将变为351px
,并且当UA尝试为background-size
计算宽度的50%时,结果值为175.5px
。这就是渔获物所在的地方。 Some browsers round it down to 175px
, some like FF has unique logic which rounds down some but rounds up the others, some just round it up etc。将该值四舍五入后,两个背景块的总大小变为350px,但框的实际宽度为351px,此1px的差异就是您看到的间隙。
问题2:在元素上应用变换时,总是会出现这种差距。我的感觉是,这与元素的背面有关,因为当我们将backface-visibility
Đặt thànhẩn giấu
时,它会消失。我们在答案的底部添加了详细的说明。 (这已在Chrome中进行了测试,但应该可以全部使用。如果没有,则没有解决方案。)
在以下代码段中,我已修复了这两个问题,您可以看到它的工作方式。 backface-visibility: hidden
还有一个额外的收获。在容器元素上设置此元素时,该元素内的所有文本都会变得模糊。因此,最好使用伪创建背景,因为它不会影响P
元素的显示。
* {
lề: 0;
outline: 0;
border: 0;
}
.round {
vị trí: tương đối;
width: 300px;
height: 300px;
padding: 30px;
}
.round:after {
vị trí: tuyệt đối;
content: '';
height: 100%;
width: 100%;
top: 0px;
left: 0px;
background: radial-gradient(circle at 0 100%, rgba(204, 0, 0, 0) 70%, #c00 71%), radial-gradient(circle at 100% 100%, rgba(204, 0, 0, 0) 70%, #c00 71%), radial-gradient(circle at 100% 0, rgba(204, 0, 0, 0) 70%, #c00 71%), radial-gradient(circle at 0 0, rgba(204, 0, 0, 0) 70%, #c00 71%);
background-position: bottom left, bottom right, top right, top left;
background-size: 50% 50%;
background-repeat: no-repeat;
transform: rotate(45deg);
backface-visibility: hidden;
z-index: -1;
}
p {
width: 125px;
margin: 85px;
}
By using radial gradients, you can simulate rounded corners with a negative radius. Just in this case,
translateZ(1px)
来完成此操作。正如他还指出的那样,在某些机器中,这也改善了抗锯齿功能。
* {
lề: 0;
outline: 0;
border: 0;
}
.round {
vị trí: tương đối;
width: 300px;
height: 300px;
padding: 30px;
background: radial-gradient(circle at 0 100%, rgba(204, 0, 0, 0) 70%, #c00 71%), radial-gradient(circle at 100% 100%, rgba(204, 0, 0, 0) 70%, #c00 71%), radial-gradient(circle at 100% 0, rgba(204, 0, 0, 0) 70%, #c00 71%), radial-gradient(circle at 0 0, rgba(204, 0, 0, 0) 70%, #c00 71%);
background-position: bottom left, bottom right, top right, top left;
background-size: 50% 50%;
background-repeat: no-repeat;
transform: rotate(45deg) translateZ(1px);
}
p {
transform: rotate(-45deg) translateZ(-1px);
width: 125px;
margin: 85px;
}
By using radial gradients, you can simulate rounded corners with a negative radius. Just in this case,
backface-visibility
,
translateZ
)都会导致创建图层。现在,该元素首先以其正常形式绘制(不旋转),然后单独旋转图层。因此,分离点沿直线而不是对角线,因此不需要50-50的逻辑。当我们检查答案中的两个片段时,我们可以在元素周围看到一个橙色的边框(该片段不存在)。这是图层的边框(我们通过之前的设置启用了它的显示)。
关于css - 径向渐变显示一些背线,间隙,空格或边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41755466/
Tôi là một lập trình viên xuất sắc, rất giỏi!