图片右边的文字,js

时间:2017-11-14 03:48:42

标签: javascript

我有一个div,在div里面我有一张照片和一张文字。现在文字出现在图片的底部,如果文字很大,那么我们看不到整个文字,我想要的是左侧的图片和图片右侧的文字,一切都应该适合于文本,如需了解更多信息,请查看图片,我们将非常感谢您的帮助。enter image description here

3 个答案:

答案 0 :(得分:2)

将图像浮动到左侧。在你的CSS中:

img{float: left;}

答案 1 :(得分:1)

为图片设置float: left可能是您需要的

https://jsfiddle.net/1kvykb18/

答案 2 :(得分:1)

对于设计和DOM样式问题,您必须选择CSS标记。在那里,我尝试通过查看您的图像来尝试此代码。为了浮动图像,您只能使用float: left,或者您可以尝试使用此代码。

HTML :

<div class="post-container">
    <h3 class="post-title">Post title</h3>
    <div class="post-thumb"><img src="your image url"/></div>
    <div class="post-content">
        <p>this is a test this is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a testthis is a test </p></div>
</div>

CSS:

.post-container {
    margin: 20px 20px 0 0;  
    border: 1px solid #333;
    overflow: auto
}
.post-thumb {
    float: left
}
.post-thumb img {
    display: block
    height : 200px;width:200px;
}
.post-content {
    margin-left: 210px
}
.post-title {
    font-weight: bold;
    font-size: 200%;
    padding: 9px;
    background: #ccc
}