我想更改我的 <h2>
发短信给<p>
.但我希望它看起来与 <h2>
相同文本。
我试过更改我的 CSS 无济于事:
<section id="" class="form container-fluid">
<form id="frm_contact" action="" method="post" enctype=multipart/form-data" style="">
<h2>Make an Enquiry</h2>
<p>Make an Enquiry</p>
<p>Please ask us about any parts you need and we’ll get back to you shortly.</p>
文本显然作为标准 p 文本返回,但我不知道应该在哪里更改代码。
我希望“进行查询”(当前为 h2)为 <p>
, 但看起来还是一样。
最佳答案
大多数浏览器显示<h2>
使用这些默认值 Source :
h2 {
display: block;
font-size: 1.5em;
margin-top: 0.83em;
margin-bottom: 0.83em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
}
因此,最好的办法是向 <p>
添加一个类具有上述属性的元素。
HTML
<p class="text-mod">Make an Enquiry</p>
CSS
.text-mod{
display: block;
font-size: 1.5em;
margin-top: 0.83em;
margin-bottom: 0.83em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
}
编辑: 好吧,既然上面的解决方案没有奏效,那肯定是因为特异性。
尝试使用 !important 覆盖属性:
.text-mod{ display: block !important;
font-size: 1.5em !important;
margin: 0.83em 0 !important;
font-weight: bold !important;
}
注意:使用 !important 是一种极端措施,仅在没有其他方法时才推荐使用。
关于html - 如何在保持大小和对齐的同时将 h2 标题更改为 <p> 文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56695770/