html - 容器中图像右侧的文本(多个图像)

标签 html css image text css-float

我正在制作一个包含 3 个图像和三个“文本位”的容器

我的问题是我似乎无法让文本出现在每张图片的右侧。 这里有一个 SS:http://imgur.com/ujBIjYC

HTML:

        <div class="textandimg">
        <div class="image">
        <a href="#">
        <img src="img/belahotellforside.png" alt="belahotellforside">
        </a>
        </div>
        <div class="text">
        <p>asdfer</p>
        </div>
        <div class="image">
        <a href="#">
        <img src="img/caprocatforside.png" alt="caprocatforside">
        </a>
        </div>
        <div class="text">
        <p>asdfer</p>
        </div>
        <div class="image">
        <a href="#">
        <img src="img/granhotellforside.png" alt="granhotellforside">
        </a>
        </div>
        <div class="text">
        <p>asdfer</p>
        </div>



 </div>

和CSS:

.textandimage{
clear:both;
}
.image{
float:left;
width: 100%;
margin-left: 10px;
}
.text{
float:left;
}

如果我输入:

.text{
 float:right;
 }

文本显示在右侧。但它仍然与图片一致。我希望文本并排显示。

感谢任何帮助。谢谢。

最佳答案

如果您的带有 image 类的 div 设置了 width: 100% 它会占用 100% 的宽度。因此,您可以将其删除或设置为以“px”为单位的值。

关于html - 容器中图像右侧的文本(多个图像),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20023904/

相关文章:

PHP - 从两个 JPEG 图像创建简单的动画 GIF?

html - 居中图像

javascript - Jquery 菜单行为不稳定、定位错误和一般错误

html - 3列引导网格布局麻烦

html - 将不同大小的图像放入同一类的 div 中,div 的数量等于图像总数

javascript - 将事件类分配给使用 For 循环创建的 Clicked 按钮

html - 无法滚动到溢出容器的 flex 元素的顶部

PHPExcel - 加载和写入后尝试插入图像时出错

javascript - 如何在我的变量中使用本地存储值?

html - 如何在 HTML 表格中放大我的 SVG?