简体   繁体   中英

Error with border-radius in chrome

I'm making a simple animation for preloading a web site. It's really simple. Here is my code:

http://jsfiddle.net/sqxsf18b/

 <div id="loader-wrapper">
    <div id="loader">

    </div>
 </div>

 #loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
}


#loader {

    display: block;
    position: relative;
    left: 50%;
    top: 50%;
    width: 150px;
    height: 150px;
    margin: -75px 0 0 -75px;
    border-radius: 50em;
    border: 3px solid transparent;
    border-top-color: #3498db; 
    -webkit-animation: spin 2s linear infinite;
    animation: spin 2s linear infinite;
}

#loader:before{
    content: "";
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: #e74c3c; 
    -webkit-animation: spin 3s linear infinite;
    animation: spin 3s linear infinite;
}

#loader:after{
    content: "";
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: #f9c922;
    -webkit-animation: spin 1.5s linear infinite;
    animation: spin 1.5s linear infinite;
}

@-webkit-keyframes spin {
    0% { 
        -webkit-transform: rotate(0deg);  
        -ms-transform: rotate(0deg);  
        transform: rotate(0deg);  
    }
    100% { 
        -webkit-transform: rotate(100deg);  
        -ms-transform: rotate(100deg);  
        transform: rotate(100deg); 
    }
}
@keyframes spin {
    0% { 
        -webkit-transform: rotate(0deg);  
        -ms-transform: rotate(0deg);  
        transform: rotate(0deg);  
    }
    100% { 
        -webkit-transform: rotate(100deg);  
        -ms-transform: rotate(100deg);  
        transform: rotate(100deg); 
    }
}

It's so weird, in jsfiddle works, but does not on chrome.

the border-radius attribute works on the #loader.before and #loader.after but does not on #loader. I've seen so many solutions but no one worked. Can anyone solve this?

Your code works fine for me in Chrome. Can you post more information about the rendering problem you're experiencing?

Also is there a reason you've declared border-radius as % on the two inner circles but em for the parent?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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