1

This is giving me a headache...

I'm trying to have an image of fixed height/width on the left, and text on the right, in the same line of course. The overall container has a dynamic width of 90% of viewport, meaning that the text on the right will also have a dynamic width (90% - image width) since the image on the left is fixed. The text needs to be aligned left, so "float:right" won't work. I've tried countless combinations of floats, aligns, table cells, etc, nothing works... closest I've got to was they were in the same line, but the text was forced aligned to the right.

Image of what I mean: http://i.imgur.com/QRDhLro.png

#container {
overflow:hidden;
position:relative;
width:90%;
min-width:800px;
margin-bottom:20px;
margin-top:20px;
margin-left:auto;
margin-right:auto;
}
.leftimage {
width:600px;
height:100px;
}
.righttext {    
float:right;
}

...
...

<div id="container">

    <div class="righttext">lorem ipsum lorem ipsum <br> lorem ipsum lorem ipsum </div>

    <div class="leftimage"><img src="../pictures/test.png"></div>

</div>
4

2 回答 2

6

移动

<div class="righttext">lorem ipsum lorem ipsum <br> lorem ipsum lorem ipsum </div>

<div class="leftimage"><img src="../pictures/test.png"></div>

CSS:

.righttext{
    float: none;
    margin-left: 600px;
}
于 2013-03-25T19:15:46.923 回答
4

也许只是:

<img src="#" align="left">
<p>This is my paragraph to the right of my image</p>

这确实有效,如此处所示:http: //jsfiddle.net/tWqwh/

于 2013-03-25T19:15:01.743 回答