I've been struggling to achieve the following task: I want to have a <div>
element that takes up the entire width of its parent div. Within this, I aim to place A. some text and B. an image.
A. The text (which can be loose or wrapped in a <p>
, <h2>
, <span>
, or <div>
element) should be on the left.
B. An image defined with an <img>
tag where both height and width are known.
Additional requirements:
There should be 12px of space between the text and the
<img>
element.Crucially, both the text from A. and the image from B. must be centered as a group.
The text from A. needs to be vertically centered within its container.
How can I accomplish this arrangement? Despite my attempts, I am unable to position the image next to the text or get the text A. properly centered vertically.
Does anyone have a solution for this straightforward issue?
Thank you all for providing your answers; it seems CSS can make simple tasks incredibly challenging. In any case:
div#content_whatsnew, div#content_bestsellers { clear: both; height: 108px; font-size: xx-large; text-transform: uppercase; margin-left: 380px; }
div#content_whatsnew p, div#content_bestsellers p { float: left; height: 108px; line-height: 108px; padding: 8px 12px 0px 0px; color: black; }
div#content_whatsnew img, div#content_bestsellers img { float: left; height: 108px; }