首页 > 解决方案 > 为什么我的段落不左对齐?

问题描述

我希望段落左对齐

我的 HTML 或 CSS 有问题吗?

<ul class="imp">
    <h2 <li>Born: August 11, 1967 (age 53 years), Newark, New Jersey, United States </li> </h2>
    <h2 <li>Height: 1.71 m </li></h2>
    <h2 <li>Children: 2 </li></h2>
    <h2 <li>Spouse: Jessica Ditzel (m. 2009)</li></h2>
<ul/>

<div>
    <p><h2>He has also worked as a television host and an actor. Rogan began his career in comedy in August 1988 in the Boston area. After relocating to Los Angeles in 1994, he signed an exclusive developmental deal with Disney, and appeared as an actor on several television shows including Hardball and NewsRadio. In 1997, he started working for the Ultimate Fighting Championship (UFC) as an interviewer and color commentator. Rogan released his first comedy special in 2000. From 2001 to 2006, he was the host of Fear Factor. In 2009, Rogan launched his podcast The Joe Rogan Experience, which led him to "fame, wealth and podcast superstardom".</h2></p>
</div>

CSS 代码:

.imp {
    padding: 0px;
    text-align: left;
    font-family: 'Roboto', sans-serif;
    font-weight: 900;
}
.para {
    padding: 0px;
    margin-left: 0px;
    text-align: left;
    font-family: 'Roboto', sans-serif;
    font-weight: 900;
}

标签: htmlcss

解决方案


应该是评论,但我看到你是新手,所以我想回答更多细节。

  • 文本默认左对齐
  • 如果你使用 list ulli应该直接指向孩子而不是其他标签。
  • <p>不应该换行标题h2
  • CSS 中的类应该通过以下方式应用于 HTML<tagname class="class-name">...</tagname>

基本上,您的 HTML 错误,而不是 CSS。


推荐阅读