html - 文本在 HTML 中的定位问题

标签 html css positioning

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

enter image description here

如您所见,段落出现在其他所有内容下方,但这不是它在我的 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;
}

最佳答案

你已经将 Float:left 添加到仅 right Div,你还需要使用以下代码更新你的 left div

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

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

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

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

关于html - 文本在 HTML 中的定位问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13951318/

相关文章:

jQuery HTML 到 JSON,包括 href 属性

html - 这些空白是从哪里来的?

css - 奇怪的 CSS 问题?使用 float 属性定位 div 元素

css - div 之间的额外空间,另一个

css - 如何使用定位属性网站

从 HTML 中抓取 C++ 屏幕

javascript - post()请求后在jquery中显示图像

html - 使用 Bootstrap 默认选择单选按钮

javascript - 从任意 HTML 表创建工具提示输出

html - 如何使用 CSS FlexBox 创建这种复杂的页面布局