我正在尝试将 div 标记中的图像对齐到最右侧。我用谷歌搜索并尝试了一些选项,例如 class="rounded float-right"和 class="pull-right"但 img 停留在最左边。任何帮助表示赞赏。谢谢,
<div>
<a>
<div>
<img src="/assets/img/myimage.gif" class="rounded float-right"/>
</div>
</a>
</div>
最佳答案
很难说出你真正想要什么,因为没有太多的上下文,但是下面的例子怎么样
a {
display: block;
width: 100%;
text-align: right;
}
<div>
<a>
<div>
<img src="https://cdn.pixabay.com/photo/2014/09/03/20/15/legs-434918_960_720.jpg" class="rounded float-right"/>
</div>
</a>
</div>
或者:
a {
display: block;
width: 100%;
position: relative;
}
a img {
position: absolute;
right: 0;
}
<div>
<a>
<div>
<img src="https://cdn.pixabay.com/photo/2014/09/03/20/15/legs-434918_960_720.jpg" class="rounded float-right"/>
</div>
</a>
</div>
关于css - bootstrap 4 html 将图像对齐到元素的末尾/右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52044386/