英文:
When I set the border radius, the color of the border is fade out, its looks buggy. How to solve this?
问题
我使用边框半径50%创建了简单的圆圈,但边框的颜色渐变,意味着颜色扩散开来。如何解决这个问题?我尝试使用::after来创建边框,但没有起作用。
这是我的代码:
.category-row {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.category-item {
margin-bottom: 10px;
padding: 15px;
}
.image-box {
width: 140px;
height: 140px;
border-radius: 50%;
display: table;
position: relative;
margin: 0 auto 24px;
background: #FBF4F3;
border: 1px solid #AF3D78;
}
.category-title {
text-align: center;
}
<div class="category-row">
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<!-- 其他类似结构 -->
</div>
这是我的问题。我想要一个平滑的边框颜色。
英文:
I have created simple circles using border radius 50% but the color of border is fading means color is spread out. How to Solve this ?, I have tried to create border using ::after but that doesn't work.
Here is my code:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.category-row {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.category-item {
margin-bottom: 10px;
padding: 15px;
}
.image-box {
width: 140px;
height: 140px;
border-radius: 50%;
display: table;
position: relative;
margin: 0 auto 24px;
background: #FBF4F3;
border: 1px solid #AF3D78;
}
.category-title {
text-align: center;
}
<!-- language: lang-html -->
<div class="category-row">
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<!-- end snippet -->
<a href="https://i.stack.imgur.com/bZteO.png"><img src="https://i.stack.imgur.com/bZteO.png"></a>
I want a smooth border color.
答案1
得分: 1
你在圆形边缘的抗锯齿上遇到了问题。通过混合边框和背景颜色创建渐变效果,抗锯齿是一种软化锯齿状边缘的技术。这有时会导致边框颜色看起来淡或分散。
使用 outline 属性而不是 border 属性来创建圆形边框是修复此问题的一种技术。在不改变元素或其周围内容的布局的情况下,outline属性在元素的边框边缘之外绘制一条线。
CSS 代码:
.image-box {
width: 140px;
height: 140px;
border-radius: 50%;
display: table;
position: relative;
margin: 0 auto 24px;
background: #FBF4F3;
outline: 1px solid #AF3D78;
}
英文:
You seem to be having problems with anti-aliasing on the circle's border. By creating a gradient effect by blending the border and background colors, anti-aliasing is a technique used to soften jagged edges. This occasionally results in the border colour looking faded or dispersed.
Creating the circle border using the outline property rather than the border property is one technique to fix this. Without changing the layout of the element or the content around it, the outline property draws a line outside the element's border edge.
CSS code:
.image-box {
width: 140px;
height: 140px;
border-radius: 50%;
display: table;
position: relative;
margin: 0 auto 24px;
background: #FBF4F3;
outline: 1px solid #AF3D78;
}
答案2
得分: 0
请在移动设备上打开您的jsfiddle链接并进行缩放。它没有淡出效果。外观可能会因分辨率和屏幕大小而有所不同。
否则,您可以尝试将边框宽度增加到2像素:
.category-row {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.category-item {
margin-bottom: 10px;
padding: 15px;
}
.image-box {
width: 140px;
height: 140px;
border-radius: 50%;
display: table;
position: relative;
margin: 0 auto 24px;
background: #FBF4F3;
border: 2px solid #AF3D78;
}
.category-title {
text-align: center;
}
<div class="category-row">
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
</div>
英文:
Please open your jsfiddle link on a mobile device and zoom it. It is not fading out. The appearance may be different depending on the resolution and screen size.
Otherwise, you can try increasing the border-width to 2px:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.category-row {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.category-item {
margin-bottom: 10px;
padding: 15px;
}
.image-box {
width: 140px;
height: 140px;
border-radius: 50%;
display: table;
position: relative;
margin: 0 auto 24px;
background: #FBF4F3;
border: 2px solid #AF3D78;
}
.category-title {
text-align: center;
}
<!-- language: lang-html -->
<div class="category-row">
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
<div class="category-item">
<div class="image-box"></div>
<div class="category-title">Fragrance</div>
</div>
</div>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论