如何在保持大小和对齐方式的同时将h2标题更改为<p>文本?

时间:2019-06-21 01:30:44

标签: css h2 title p

我想将我的<h2>文本更改为<p>。但我希望它看起来与<h2>文本相同。

我尝试将CS​​S更改为无效:

        <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>,但看起来还是一样。

Have a look at what i mean here

3 个答案:

答案 0 :(得分:2)

大多数浏览器显示的<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是一种极端的措施,只有在没有其他解决方法时才建议使用。

答案 1 :(得分:1)

我建议您将标签更改为<p>,并使用CSS样式更改其显示方式。

例如,您可以这样做:

<p class="headingText"> Make an Enquiry </p>

在您的CSS文件中:

.headingText {
       font-weight: bold;
       font-size: 14px;
     }

您可以在此处了解有关CSS的更多信息:https://www.w3schools.com/css/

如果这不能回答您的问题,请告诉我如何为您提供帮助:)

添加到CSS文件:

.makeHeader {
  font-weight: bold;
  color:#000;
  text-transform: inherit;
  font-weight: 500;
    font-size: 32px;
}

具有这样的标签:

<p class="makeHeader">Make an Enquiry</p>

答案 2 :(得分:0)

您可以尝试使用内联CSS来覆盖某些更改。

std::getline(std::cin, coursework_mark);

如果愿意,可以始终使用这种方法来更改样式。