css - bootstrap 4 html 将图像对齐到元素的末尾/右侧

标签 css

我正在尝试将 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/

相关文章:

css - 图像/CSS 转换未在 Safari 中加载

css - 响应式 3 列页面最后一列在非常窄的窗口时跳转

html - CSS 下拉导航右对齐

css - 未呈现 Internet Explorer 'input:checked + label:before' 样式

html - 无法将填充或边距应用于 "lead"类 <p> 元素

php - 如何即时反射(reflect)变化的排名?

css - 垫表列宽度在包含输入时不会改变

javascript - 如何使 flex-direction : column; properly. 我的代码不起作用

jquery - 使用 cookie 永久更改 CSS

html - 如何在不获得倾斜值的情况下使段落适合倾斜的父 div?