【发布时间】:2021-05-26 14:25:32
【问题描述】:
我想把我的图片放在页面的最右边,我尝试用position: absolute和right: 0进行修改。
我也尝试将父位置设置为相对位置,将图像位置设置为绝对位置,但为什么它不起作用?
在我的 jsx 文件中
<div className={styles.images}>
<Image
src="/cloud.svg"
alt="Picture of the author"
layout="fill"
className={styles.cloud}
/>
<Image
src="/kuil.svg"
alt="Picture of the author"
height={200}
width={600}
layout="intrinsic"
className={styles.building}
/>
</div>
也在我的 css 文件中。
.images {
position: relative;
margin: 90px auto 0 auto;
}
.building {
position: absolute;
top: 0;
right: 0 !important;
bottom: 0 !important;
}
【问题讨论】:
-
请确认其工作。您将带有
styles的 className 定义为 js object 。那么css将如何工作。你需要使用 Dom css 对象而不是普通的 css -
@prasanth 他可能在使用 CSS 模块,
styles.images返回一个字符串。 -
多么美丽的画面!