gpt4 book ai didi

html - 简单的 CSS 微调器作为 DIV 而不是 SPAN(或内联 DIV)

转载 作者:太空宇宙 更新时间:2023-11-04 15:59:20 26 4
gpt4 key购买 nike

我需要一个基本上可以插入段落文本中间的微调器。我按照我希望的方式将微调器作为 block 显示元素 (div),但是当我尝试将其创建为跨度(或将 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>

最佳答案

inline 元素无法调整大小,inline-blockinline-flexinline-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>

关于html - 简单的 CSS 微调器作为 DIV 而不是 SPAN(或内联 DIV),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42860929/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com