html - Legend tag not aligning properly - Stack Overflow

I have a form. Inside of that a fieldset inside of that a legend tag. For some reason the legend tag is

I have a form. Inside of that a fieldset inside of that a legend tag. For some reason the legend tag is not on top of the border (like it should be). Instead its underneath it, like a block element. Image of the problem

I tried adding the fieldset tag position: relative, and the legend tag padding: 0. Didnt work. Also i tried making a completely new form, outside of all bootstrap or my css code, applied the necessary styles (fieldset tag position: relative, and the legend tag padding: 0) and it had the same problem.

Here is my current html + css:

.contact-form {
  position: relative;
  padding: 10px;
  margin: 20px 10px;
  border: 1px solid #ccc;
  border-radius: 3px;
}

.contact-form > legend {
  padding: 0;
  font-size: 1.2rem;
  font-weight: bold;
  color: #333;
}
<div class="col-xl-6 col-md-12">
  <form id="contactForm" method="POST" action="some_api.php">
    <fieldset class="contact-form">
      <legend>Ajánlatkérés</legend>
      ... multiple lines of inputs, labels etc...
    </fieldset>
  </form>
</div>

I have a form. Inside of that a fieldset inside of that a legend tag. For some reason the legend tag is not on top of the border (like it should be). Instead its underneath it, like a block element. Image of the problem

I tried adding the fieldset tag position: relative, and the legend tag padding: 0. Didnt work. Also i tried making a completely new form, outside of all bootstrap or my css code, applied the necessary styles (fieldset tag position: relative, and the legend tag padding: 0) and it had the same problem.

Here is my current html + css:

.contact-form {
  position: relative;
  padding: 10px;
  margin: 20px 10px;
  border: 1px solid #ccc;
  border-radius: 3px;
}

.contact-form > legend {
  padding: 0;
  font-size: 1.2rem;
  font-weight: bold;
  color: #333;
}
<div class="col-xl-6 col-md-12">
  <form id="contactForm" method="POST" action="some_api.php">
    <fieldset class="contact-form">
      <legend>Ajánlatkérés</legend>
      ... multiple lines of inputs, labels etc...
    </fieldset>
  </form>
</div>

Share Improve this question edited Mar 13 at 11:42 Sean 8,2634 gold badges26 silver badges53 bronze badges asked Mar 13 at 11:21 PetGamerPetGamer 114 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

For some reason the tag inherited some css from other sources. I don't know from where, so i just added a few lines of css and the !important property at the end of lines. Yeah css is hard to maintain.

.contact-form > legend {
  padding: 0;
  font-weight: bold;
  color: #333;
  float: none !important;
  width: auto !important;
  margin-bottom: 0 !important;
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744704302a4588961.html

相关推荐

  • html - Legend tag not aligning properly - Stack Overflow

    I have a form. Inside of that a fieldset inside of that a legend tag. For some reason the legend tag is

    18小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信