html - 为什么我的段落不左对齐?
问题描述
我希望段落左对齐
我的 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;
}
解决方案
应该是评论,但我看到你是新手,所以我想回答更多细节。
- 文本默认左对齐
- 如果你使用 list
ul
,li
应该直接指向孩子而不是其他标签。 <p>
不应该换行标题h2
。- CSS 中的类应该通过以下方式应用于 HTML
<tagname class="class-name">...</tagname>
基本上,您的 HTML 错误,而不是 CSS。
推荐阅读
- google-apps-script - 如何判断 Google 日历活动是否重复(即系列的一部分)?
- fork - 就 PR 而言,原始回购和分叉回购之间有区别吗?
- c++ - 计算着色器管道创建崩溃
- superset - 隐藏图表标题
- android - 如何从 android 获取照片并将其放入 Xamarin 表单中的 Image 控件中?
- google-apps-script - 使用 Google Apps 脚本在 Blogger 中创建帖子
- c++ - 忽略字符串流中的空格不适用于 skipws 标志
- google-apps-script - 如何设置数据范围
- google-apps-script - 谷歌表格:保持单元格值不变如果 importhtml 返回 #N/A 错误
- bash - 重试失败的 xcodebuild 测试