Is thee anyone able to help with this?
All I want to do is place the heart image into a box.
I’m trying to do this: Image
code https://jsfiddle.net/Lkcm4jas/
I am looking to create a 400 x 400 pixel box around the heart image that I have provided. My goal is to ensure that the heart is neatly enclosed within this box, which should be clearly visible in the final composition.
How do I do that in the code?
body {
margin: 80px;
}
.left,
.right {
display: inline-block;
}
.left {
width: 170px;
height: 239px;
margin-right: -4px;
}
div > div {
display: block;
height: 34px;
}
div > div > div {
width: 30px;
height: 30px;
background-color: red;
display: inline-block;
float: right;
margin: 2px;
}
div.right > div > div {
float: left;
}
<div class="left">
<div style="padding-right: 68px">
<div></div>
<div></div>
</div>
<div style="padding-right: 34px">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div>
<div></div>
<div></div>
<div></div>
</div>
<div>
<div></div>
<div></div>
</div>
<div>
<div></div>
</div>
</div>
<div class="right">
<div style="padding-left: 34px">
<div></div>
<div></div>
</div>
<div style="">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div>
<div></div>
<div></div>
<div></div>
</div>
<div>
<div></div>
<div></div>
</div>
<div>
<div></div>
</div>
</div>
2
Answers
If you wrap everything in another element, then you can set it’s size to 400×400 and center it’s contents.
I used
<main>
but you could just as well use a<div>
I did a similar design previously using a single element: