【发布时间】:2022-02-02 00:35:37
【问题描述】:
我想得到这样的东西:
这是当前的结果:
我尝试过的:
.accordion-button::after {
flex-shrink: 0;
width: 1.25rem;
height: 1.25rem;
margin-left: auto;
content: "";
background-image: url(data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23212529'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e);
background-repeat: no-repeat;
background-size: 1.25rem;
transition: transform .2s ease-in-out;
float: left;
}
很遗憾,float: left; 没用。
有什么想法吗?
更新:
如果我按照佐藤健的建议去掉margin-left: auto,图标会更靠近文本,但仍会向右对齐。
【问题讨论】:
-
删除
margin-left: auto。 -
感谢您的评论佐藤さん、是的,我之前也尝试过,它的作用是将图标移近文本,但仍会向右对齐。
-
用@SatoTakeru 评论更新问题
标签: css twitter-bootstrap