如何将H1移动到与DIV顶部对齐的位置

时间:2012-01-10 05:55:29

标签: html css

我无法将<h2 class="feature_description_content">垂直对齐图像左侧。您可以看到它比图像的顶部低很多,而且我似乎找不到负责它的CSS。

这是一张图片:

enter image description here

以下是代码:

<div class="feature feature-item-248">
                <img class="main" src="http://www.bolistylus.com/wp-content/uploads/uclaproduct.png" alt="" /></p>
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">PERFECTLY WEIGHTED</h2>

</div>
<div class="feature_description_content">
<p>Touch screens have simplified technology, but there has yet to be a way to capture the precision of a calligrapher or the stroke of an artist. Not only should it meet your needs, but a stylus should have style.</p>
</div></div>
</p></div>

由于

3 个答案:

答案 0 :(得分:3)

此问题必须归因于默认边距和默认HTML元素的填充,您必须通过设置

来尝试

h2 { margin:0px; padding:0px; }

然后根据需要更改填充

答案 1 :(得分:1)

设置其margin-top: 0; - 简单:)

答案 2 :(得分:0)

图像假设向左浮动并且双向清除,因此文本可以正确对齐...

 img .main {
 float: left;
 clear: both;
 }