2017-03-17 1 views
1

基本的に段落テキストの中央に挿入できるスピナーが必要です。私はブロック表示要素(div)としてスピナーを使用していますが、スパンとして作成しようとすると(またはdivをインラインに変更すると)、スピナーは機能しません。シンプルなCSSスピナーはDIVとして機能しますが、SPAN(またはインラインDIV)としては機能しません

このスピンナーを修正して、文章の途中にドロップできるようにするにはどうすればよいですか(段落テキスト)?

#loader { 
 
    float: left; 
 
    width: 10px; 
 
    height: 10px; 
 
    margin-right: 5px; 
 
    margin-top: 2px; 
 
    border: 2px solid #f3f3f3; 
 
    border-radius: 50%; 
 
    border-top: 2px solid #3498db; 
 
    -webkit-animation: spin 2s linear infinite; 
 
    animation: spin 2s linear infinite; 
 
} 
 

 
#loaderInline { 
 
    display: inline; 
 
    width: 10px; 
 
    height: 10px; 
 
    margin-right: 5px; 
 
    margin-top: 2px; 
 
    border: 2px solid #f3f3f3; 
 
    border-radius: 50%; 
 
    border-top: 2px solid #3498db; 
 
    -webkit-animation: spin 2s linear infinite; 
 
    animation: spin 2s linear infinite; 
 
} 
 

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

 
@keyframes spin { 
 
    0% { 
 
    transform: rotate(0deg); 
 
    } 
 
    100% { 
 
    transform: rotate(360deg); 
 
    } 
 
} 
 

 

 
/* Add animation to "page content" */ 
 

 
.animate-bottom { 
 
    position: relative; 
 
    -webkit-animation-name: animatebottom; 
 
    -webkit-animation-duration: 1s; 
 
    animation-name: animatebottom; 
 
    animation-duration: 1s 
 
} 
 

 
@-webkit-keyframes animatebottom { 
 
    from { 
 
    bottom: -100px; 
 
    opacity: 0 
 
    } 
 
    to { 
 
    bottom: 0px; 
 
    opacity: 1 
 
    } 
 
} 
 

 
@keyframes animatebottom { 
 
    from { 
 
    bottom: -100px; 
 
    opacity: 0 
 
    } 
 
    to { 
 
    bottom: 0; 
 
    opacity: 1 
 
    } 
 
}
<p> 
 
    <div id="loader"></div>Works as normal DIV 
 
</p> 
 

 
<p> 
 
    <div id="loaderInline"></div>Broken as DIV with inline display 
 
</p>

答えて

2

inline要素は、inline-blockinline-flex又はinline-tableサイズないこととインラインボックスとして相互作用することができません。

#loader { 
 
    float: left; 
 
    width: 10px; 
 
    height: 10px; 
 
    margin-right: 5px; 
 
    margin-top: 2px; 
 
    border: 2px solid #f3f3f3; 
 
    border-radius: 50%; 
 
    border-top: 2px solid #3498db; 
 
    -webkit-animation: spin 2s linear infinite; 
 
    animation: spin 2s linear infinite; 
 
} 
 

 
#loaderInline { 
 
    display: inline-block; 
 
    width: 10px; 
 
    height: 10px; 
 
    margin-right: 5px; 
 
    margin-top: 2px; 
 
    border: 2px solid #f3f3f3; 
 
    border-radius: 50%; 
 
    border-top: 2px solid #3498db; 
 
    -webkit-animation: spin 2s linear infinite; 
 
    animation: spin 2s linear infinite; 
 
} 
 

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

 
@keyframes spin { 
 
    0% { 
 
    transform: rotate(0deg); 
 
    } 
 
    100% { 
 
    transform: rotate(360deg); 
 
    } 
 
} 
 

 

 
/* Add animation to "page content" */ 
 

 
.animate-bottom { 
 
    position: relative; 
 
    -webkit-animation-name: animatebottom; 
 
    -webkit-animation-duration: 1s; 
 
    animation-name: animatebottom; 
 
    animation-duration: 1s 
 
} 
 

 
@-webkit-keyframes animatebottom { 
 
    from { 
 
    bottom: -100px; 
 
    opacity: 0 
 
    } 
 
    to { 
 
    bottom: 0px; 
 
    opacity: 1 
 
    } 
 
} 
 

 
@keyframes animatebottom { 
 
    from { 
 
    bottom: -100px; 
 
    opacity: 0 
 
    } 
 
    to { 
 
    bottom: 0; 
 
    opacity: 1 
 
    } 
 
}
<p> 
 
    <div id="loader"></div>Works as normal DIV 
 
</p> 
 

 
<p> 
 
    <div id="loaderInline"></div>Broken as DIV with inline display 
 
</p>


あなたにも擬似:before/::beforeinline-blockを使用することがあります。

#loader { 
 
    float: left; 
 
    width: 10px; 
 
    height: 10px; 
 
    margin-right: 5px; 
 
    margin-top: 2px; 
 
    border: 2px solid #f3f3f3; 
 
    border-radius: 50%; 
 
    border-top: 2px solid #3498db; 
 
    -webkit-animation: spin 2s linear infinite; 
 
    animation: spin 2s linear infinite; 
 
} 
 

 
p:before { 
 
    content: ''; 
 
    display: inline-block; 
 
    width: 10px; 
 
    height: 10px; 
 
    margin-right: 5px; 
 
    margin-top: 2px; 
 
    border: 2px solid #f3f3f3; 
 
    border-radius: 50%; 
 
    border-top: 2px solid #3498db; 
 
    -webkit-animation: spin 2s linear infinite; 
 
    animation: spin 2s linear infinite; 
 
} 
 

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

 
@keyframes spin { 
 
    0% { 
 
    transform: rotate(0deg); 
 
    } 
 
    100% { 
 
    transform: rotate(360deg); 
 
    } 
 
} 
 

 

 
/* Add animation to "page content" */ 
 

 
.animate-bottom { 
 
    position: relative; 
 
    -webkit-animation-name: animatebottom; 
 
    -webkit-animation-duration: 1s; 
 
    animation-name: animatebottom; 
 
    animation-duration: 1s 
 
} 
 

 
@-webkit-keyframes animatebottom { 
 
    from { 
 
    bottom: -100px; 
 
    opacity: 0 
 
    } 
 
    to { 
 
    bottom: 0px; 
 
    opacity: 1 
 
    } 
 
} 
 

 
@keyframes animatebottom { 
 
    from { 
 
    bottom: -100px; 
 
    opacity: 0 
 
    } 
 
    to { 
 
    bottom: 0; 
 
    opacity: 1 
 
    } 
 
}
<p> 
 
    an inline-block pseudo works too; 
 
</p>