【问题标题】:Getting weird indent from style tags in html code从 html 代码中的样式标签中获取奇怪的缩进
【发布时间】:2016-10-27 21:14:14
【问题描述】:

我对 HTML 有点生疏,我在测试站点的样式代码中遇到了问题。我在<h4> 标签后得到了一个非常奇怪的缩进,我不确定问题是什么。我将包含整个 div 和屏幕截图,以便更好地解决此问题。

div style="color: #777;background-color:white; text-align: justify; margin-left: 20px; margin-right: 20px;">
<h1 style= "text-align: center;"> My Experience</h1>

        <span>
                <h4 style= "text-align: right;">April 2014- Present</h4>
                <h4>General Motors</h4>
                <h5>Senior Program Manager</h5>
                <p>

                    <ul>
                        <li>
                        End to end responsibility for the success of
                        the critical global IT projects that will evolve and transform
                        GM’s business processes and capabilities. 
                        </li>
                        <li>
                        Management of the IT project life cycle from definition to deployment,
                        through engagement with senior GM leaders, cross-functional stakeholders,
                        and development teams
                        </li>
                    </ul>

                </p>

            <p>
            <h4 style= "text-align: right;">May 2012- March 2014</h4>
            <h4>Xtivia, INC</h4>
            <h5>PMO Manager</h5>

                <ul>
                    <li>
                    Provided direct leadership, organization and coordination to drive the delivery of complex portal implementations to customers in multiple sectors. 
                    </li>
                    <li>
                    Guided project stakeholders in defining requirements, project scope and ensuring the effective utilization of team members. 
                    </li>
                    <li>
                    Managed PMO’s functional activities, encompassing program planning, personnel management and product delivery.
                    </li>
                </ul>
            </p>


        <h4 style = "float: left;">University of Nebrasksa - Omaha</h4><h4 style= "float: right;">June 2010 - Present</h4>
        </br>
        <h5>Adjunct Professor</h5>

        <p>
            Instructor for undergraduate Project Management and Cyber Ethics courses. 
        </p>
        <span><h4 style= "float: left;">Bellevue University</h4><h4 style= "float: right;">June 2010 - Present</h4></span>
        <br>
        <h5>Adjunct Professor</h5>

        <p>
            Instructor for graduate and undergraduate Computer Information Systems and Management Information Systems courses.
        </p>
    </span>

我确定这很简单,但是就像我之前说的,我生疏了:)

【问题讨论】:

  • 好吧,您的代码在语义上完全错误(我只是说这与手头的问题无关)。
  • 第一:停止使用内联样式,使用样式表允许缓存。其次,如果你浮动一些东西,你会把它从文档的正常流程中拿出来——有时——这会吓坏后续的兄弟姐妹。我猜&lt;h5&gt; 可能会从clear: both 中受益。顺便说一下,要详细说明之前的评论:您正在显示事物的列表,请使用列表。
  • 你应该阅读语义。好的,快速回顾一下:页面上有一个&lt;h1&gt;,其他所有内容都是其中的一个小节。 (通常&lt;h1&gt; 是页面标题/徽标等)。然后是&lt;h2&gt;,然后是&lt;h3&gt; within 带有&lt;h2&gt; 的容器。标题是后代,不用于它们通常在大小方面的外观。此外,您还奇怪地使用了 &lt;span&gt; 来包含一些标题,并使用浮点数、右对齐等有点随意。
  • 您有一堆 HTML 错误,这意味着您的 DOM 可能看起来不像您期望的那样。使用验证器:validator.w3.org/nu
  • 为什么我会因为提问而被扣分?

标签: html css text styles


【解决方案1】:

这是您的代码的正确(大部分)版本

h1 {
  text-align: center;
}
h2 {
  font-size: 1.2em;
  }
h2 span {
  float: right;
font-size: 0.75em;

}
#container {
  color: #777;
  text-align: justify; 
  margin: 0 2em;
}
<div id="container">
<h1>My Experience</h1>
  <h2>General Motors <span class="date">April 2014- Present</span></h2>
<h3>Senior Program Manager</h3>
<ul>
  <li>End to end responsibility for the success of
      the critical global IT projects that will evolve and transform
      GM’s business processes and capabilities. 
    </li>
    <li>
      Management of the IT project life cycle from definition to deployment,
      through engagement with senior GM leaders, cross-functional stakeholders,
      and development teams
    </li>
  </ul>

<h2>Xtivia, INC <span class="date">May 2012- March 2014</span></h2>
<h3>PMO Manager</h3>

<ul>
  <li>
    Provided direct leadership, organization and coordination to drive the delivery of complex portal implementations to customers in multiple sectors. 
  </li>
  <li>
    Guided project stakeholders in defining requirements, project scope and ensuring the effective utilization of team members. 
  </li>
  <li>
    Managed PMO’s functional activities, encompassing program planning, personnel management and product delivery.
  </li>
</ul>

<h2>University of Nebrasksa - Omaha <span class="date">June 2010 - Present</span></h2>
<h3>Adjunct Professor</h3>

<p>
  Instructor for undergraduate Project Management and Cyber Ethics courses. 
</p>
<h2>Bellevue University <span class="date">June 2010 - Present</span></h2>
<h3>Adjunct Professor</h3>

<p>
  Instructor for graduate and undergraduate Computer Information Systems and Management Information Systems courses.
</p>
</div>

【讨论】:

  • 这真的很有意义!显然我在语义上错过了标记,这是我第一次尝试没有像 Dreamweaver 这样的东西。感谢您的帮助。
  • 我的想法完全正确。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-09-24
  • 1970-01-01
  • 1970-01-01
  • 2013-10-29
  • 1970-01-01
  • 2013-05-08
  • 2012-02-09
相关资源
最近更新 更多