I have tried to put the padding and margin in the parent container to 0, but still the image cannot fill to the edges. this is my img.
This is my js file:
import styles from './css/Home.module.css';
export default function home()
{
return(
<>
<div className= {styles.container}>
<div className= {styles.pictures}>
<img src = "../pictures/home.jpg"/>
</div>
</div>
</>
)
}
this is my css file:
.container{
/* position: absolute;
display: flex;
justify-content: center;
margin:0;
padding:0;
height: 100%;
width: 100%; */
margin: 0;
padding: 0;
}
.container .pictures img{
/* max-width: 100%;
max-height: auto;
margin-right: 10%;
padding: 0px;
border: 10px solid orange;
border-top-right-radius: 12px;
border-top-left-radius: 12px;
border-bottom-left-radius: 12px;
border-bottom-right-radius: 12px; */
margin-right: 20px;
}
please help, because I have been stuck with this problem for the past two days
I have tried to put padding and margin to 0 in the parent container, but nothing changes. I have also tried to use margin-right to move the picture to the left, but it didn’t work as well, so now I am so confused on what is the problem within my code.
2
Answers
Just Use this CSS instead of the one that you provided
I have made the picture container’s position relative and its image’s position absolute so now it will always be inside the container and you can decide how much height and width you want to give to it, also if you want to fit the image properly inside then uncomment this
object-fit
line and it will fit in the image properly.Worked fine when I tested your code. Are you sure it’s not the padding/margin from an element higher up? It might even be the margin of the
body
element.