0

我正在尝试在图像和项目符号之间放置一个段落。我认为我在 html 中有正确的布局,但由于某种原因,它只是没有正确显示。见下图:

在此处输入图像描述

如您所见,这些段落出现在其他所有内容下,但这不是它在我的 html 中的显示方式。请参阅下面的代码:

HTML:

<div class="services">
        <div class="serviceHolder" style="opacity: 1;">
            <div class="serviceBox" id="service-plan">
                <div class="serviceIcon"><img src="images/icon-design.jpg" width="129" height="134" alt="design icon"></div>
                <div class="serviceCopy">
                    <h2>Plan</h2>
                    <ul class="serviceBullets">
                        <li><h3>Objectives</h3></li> 
                        <li><h3>Scope</h3></li>
                        <li><h3>Sitemap</h3></li>
                        <li><h3>Wireframes</h3></li>
                    </ul>   
                    <p>Lorem ipsum dolor sit amet, porta quis urna tempor vestibulum purus, vulputate condimentum arcu faucibus aliquam enim accumsan, a nulla nullam morbi bibendum eveniet tempus, parturient consequat sociis quis. Suscipit in vitae ornare lobortis sed, porta et minima odio neque maecenas cras, justo in. </p>
                    <p>Justo arcu lacus, quos pellentesque nam sit. Luctus mauris egestas, leo nisl porttitor urna scelerisque ut, mauris sodales sapien donec dolor, arcu a ante vestibulum lorem vitae quam</p>
                </div>
            </div>
        </div>

CSS:

.services {
width: 100%; float: left; margin: 30px 0;
}

.services .serviceBox {
width: 898px; padding: 30px; border: 1px solid #43C0C2; background-color: white; float:     left; margin-bottom: 10px;
}

.services .serviceIcon {
float: left; margin: 0 30px 50px 0; width: 129px;
}

.serviceBullets {
float: right; font-weight: 100; width: 150px;
}

.serviceBullets li {
list-style-image: url(../images/bullet.gif); color: #43C0C2; margin-bottom: 10px;
}

.services h2 {
font-size: 40px; margin-bottom: 20px; color: #000000;
}
4

2 回答 2

0

您是否试图让它成为图像 - 计划和段落 - 项目符号?

或者

IMAGE - 其他所有内容,以便图像列在左侧,其他所有内容都在右侧?

如果是前者。

尝试这个:

<div class="serviceHolder" style="opacity: 1;">
        <div class="serviceBox" id="service-plan">
            <div class="serviceIcon"><img src="images/icon-design.jpg" width="129" height="134" alt="design icon"></div>
            <div class="serviceCopy">
            <h2>Plan</h2>
                <p>Lorem ipsum dolor sit amet, porta quis urna tempor vestibulum purus, vulputate condimentum arcu faucibus aliquam enim accumsan, a nulla nullam morbi bibendum eveniet tempus, parturient consequat sociis quis. Suscipit in vitae ornare lobortis sed, porta et minima odio neque maecenas cras, justo in. </p>
                <p>Justo arcu lacus, quos pellentesque nam sit. Luctus mauris egestas, leo nisl porttitor urna scelerisque ut, mauris sodales sapien donec dolor, arcu a ante vestibulum lorem vitae quam</p>
             </div>
            <div class="serviceBullets">
                <ul>
                    <li><h3>Objectives</h3></li> 
                    <li><h3>Scope</h3></li>
                    <li><h3>Sitemap</h3></li>
                    <li><h3>Wireframes</h3></li>
                </ul>   
            </div>
        </div>
    </div>

这样它就有自己的 div 和项目符号是分开的。

然后把它们全部浮起来。并定义它们的宽度。然后再添加一个 div,以清除浮动。

于 2012-12-19T13:02:41.460 回答
0

您只添加Float:leftright Div,您left div还需要使用以下代码更新您的

.serviceCopy
{
  float: left;
  width: 721px;
}

同样在 2 div 之后,您需要再添加 1 个 div 以清除所有浮动

<div class="serviceIcon"></div>
<div class="serviceCopy"></div>
<div style="clear:both"></div>

这样您的布局就不会中断。

于 2012-12-19T11:46:16.173 回答