[SOLVED] Set an image in div

Hi everyone I have a problem I want put an image an a div
<body>
<div class="pic">





</div>
</body>
<body>
<div class="pic">





</div>
</body>
my css: ```css .pic{ width: 300px; height: 400px; background-image: url('img/lol.jpg'); background-attachment: fixed; background-position: center; background-size: cover; } the result I have with cover
No description
7 Replies
Pat66
Pat66OP2w ago
the result with contain
Pat66
Pat66OP2w ago
No description
Pat66
Pat66OP2w ago
this what I m expected
Pat66
Pat66OP2w ago
can I have some idea to fix this problem ?
No description
Pat66
Pat66OP2w ago
thanks
Chris Bolson
Chris Bolson2w ago
If you use background-attachment: fixed; you are fixing it to the body element and not the div. This is why it is being cropped so much. Unless you need to attach it to the body for some reason, removing this should get you closer to what you want.
Pat66
Pat66OP2w ago
thanks

Did you find this page helpful?