我想把图像对齐到右上角,我怎样才能在html中做到这一点。下面是我的代码:
<img src="star.png" alt="Gold" align="right">我不想把它对齐到右边。我想把它对齐到右上角。
发布于 2021-07-24 00:19:09
您可以将其位置设为绝对位置并应用right:0和top:0
img{
position:absolute;
top:0;
right:0;
}<img src="https://www.gravatar.com/avatar/0fdacb141bca7fa57c392b5f03872176?s=48&d=identicon&r=PG&f=1" alt="Gold" align="right">
发布于 2021-08-03 05:54:23
为了更好地实践,请使用div上的位置和其中的图像。Html就像这样
<div class="images">
<img src="star.png" alt="Gold">
</div>Css类似于
<style>
.images{
position:relative;
}
.images img{
position:absolute;
top:0;
right:0;
}
</style>https://stackoverflow.com/questions/68502217
复制相似问题