How do I make a CSS triangle with smooth edges?

后端 未结 8 670
再見小時候
再見小時候 2020-12-13 13:56

I have a triangle (JSFiddle) using this CSS:

.triangle {
    width: 0;
    height: 0;
    border-top: 0;
    border-bottom: 30px solid #666699;
    border-le         


        
相关标签:
8条回答
  • 2020-12-13 14:46

    For Firefox you can add -moz-transform: scale(.9999); to make smooth edges. In your case:

    .triangle {
        width: 0;
        height: 0;
        border-top: 0;
        border-bottom: 30px solid #666699;
        border-left: 20px solid transparent; 
        border-right: 20px solid transparent;
        -moz-transform: scale(.9999);
    }
    

    Will do the trick.

    0 讨论(0)
  • 2020-12-13 14:49

    For me, using dashed for the transparent borders worked for most browsers that don't automatically smooth them and rotating 360 degrees worked for old Webkit:

    .triangle {
        width: 0;
        height: 0;
        border-top: 0;
        border-bottom: 30px solid #666699;
        border-left: 20px dashed transparent; 
        border-right: 20px dashed transparent;
        -webkit-transform: rotate(360deg);
    }
    
    0 讨论(0)
提交回复
热议问题