Quote:
Originally Posted by peace19812006
I am trying to use the image as background for the book. I use CSS like this:
div.img {
background-image: url(../images/4444.jpg);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
However, the image cannot be stretched full width. See the picture below. I don't want to see white color in this image. How can I fix that? Thanks!
|
As Turtle91 already wrote, you <div> have a margin. By adding the same margin value negatively in your <div.img> you cancel this margin. To give the text a certain margin like 10px, put it in this new margin like this CSS command.
Code:
div.img {
margin: -10px; /* use full width */
background-image: url(../images/4444.jpg);
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
div.img p {
margin: 10px; /* Move text to original location */
}