html - 如何以网格或 block 格式显示文本和图像?

标签 html css formatting

我有几个图像和文本,我想以特定格式排列,但是,尽管尝试了 display: inline-block 并使它们 float ,但我无法完全达到我需要的效果.利润率有所帮助,但他们并没有做到这一点。

我想要一张图片,然后是它旁边的一些文字,然后是下面,先是文字,然后是文字旁边的图片。如何实现下图所示的布局?

h4 {
    display: inline-block;
    font-family: helvetica;
    font-size: 15px;
    color: black;
}
<div class= "container">
    <h4>
        <center>
            <img src="Jeff Crowd.jpg" alt="Customer Service">
            <p>With a wide selection of batteries and generators, protective and decorative riding gear, helmets and accessories to fit any make and model, Great Plains is your local stop for all antique and modern motorcycle needs.</p>
            <p>With a dedicated service department comprising over 50 years experience with all makes and models, Great Plains Cycle can accomdodate any service request with efficiency and professional expertise. For any service requests, please contact us at info@example.com or stop in to speak to a professional.</p>
            <img src="Tool Box Resize.jpg"alt="Tool Box">
        </center>
    </h4>
</div>

enter image description here

最佳答案

据我了解,您应该为图像使用 float,例如:

#container img
{
    float: left;
}

看看http://www.homeandlearn.co.uk/WD/wds4p6.html

编辑:

<div class= "container">
    <h4>
        <center>
            <img id="img1" src="Jeff Crowd.jpg" alt="Customer Service">
            <p>With a wide selection of batteries and generators, protective and decorative riding gear, helmets and accessories to fit any make and model, Great Plains is your local stop for all antique and modern motorcycle needs.</p>
            <p>With a dedicated service department comprising over 50 years experience with all makes and models, Great Plains Cycle can accomdodate any service request with efficiency and professional expertise. For any service requests, please contact us at info@greatplainscycle.com or stop in to speak to a professional.</p>
            <img id="img2" src="Tool Box Resize.jpg"alt="Tool Box">
        </center>
    </h4>
</div>

和 CSS:

#img1
{
   float : left;
}

#img2
{
   float : right;
}

关于html - 如何以网格或 block 格式显示文本和图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28840576/

相关文章:

javascript - 如何使 html 中的表格外边框不同?

html - 如何在所有浏览器兼容性中设置 CSS?

css - Webpack source-map 不解析 sass 导入

css - Google 再营销标签 - iframe 高度问题

javascript - 多个div的点击显示内容,防止事件冒泡

latex - 更改 Latex 部分编号显示

html - CSS HTML 组织 5 个图像 - 跨浏览器兼容

javascript - 如何使 HTML 文本区域中的换行符导致字符串中断?

php - 格式化 if 语句以提高可读性

if-statement - 格式化具有多个条件的 if 语句的最佳方法