Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS- removing hr tag space not working

Tags:

html

css

I have read multiple posts, I've followed the instructions and still no change. What I am after is to remove the space in between the hr tag and my form. I thought by setting the margin and padding to 0 would do the fix, instead I'm getting this:

enter image description here

But instead I want something like the image below - just with a line in separating the fields.

enter image description here

html

<label for="Fridss" class="label"> F </label>
<button type="button" id="add" name="add" class="btn btn-default addButton" onClick="addInput('dynamicInput');">
  <span class="glyphicon glyphicon-plus"></span>
</button>
<input type="text" name="Fridss" id="Fri" class="open_hours" placeholder="--:--" required tabindex="16">
<span>-</span>
<input type="text" name="Fridss" id="Friday" class="open_hours" placeholder="--:--" required tabindex="17">
<hr />

css

hr {
  padding: 0;
  margin: 0;
  width: 400px;
  border-top: 1px dotted #58585b;
}
.open_hours {
  padding: 0;
  margin: 0;
  border-radius: 5px;
  width: 20%;
  height: 25px;
}

or is there a better way of creating lines in css.

like image 271
jerneva Avatar asked Oct 21 '25 11:10

jerneva


2 Answers

It really does depend on the browser's built-in styles. Check the fiddle: https://jsfiddle.net/abstractecho/7a3gzpqL/

body{color: black;}
hr {
  padding: 0 !important;
  margin: 0 !important;
  width: 400px;
  border-top: 1px dotted #58585b;
}
.open_hours {
  padding: 0;
  margin: 0;
  border-radius: 5px;
  width: 20%;
  height: 25px;
}

You may want to check if adding an margin: 0 !important to your hr css to override browser styles and let me know if it works.

like image 168
LionOnTheWeb Avatar answered Oct 25 '25 10:10

LionOnTheWeb


Nowadays hr tag is used very seldom, and if you need semantic markup, you may to use css-property border. In your case, you have classic list including similar elements, so semantic way to use ul tag and include every line in li tags.

<li>
  <label for="Fridss" class="label"> M </label>
  <button type="button" id="add" name="add" class="fa fa-plus-square-o addButton" onClick="addInput('dynamicInput');">
  </button>
  <input type="text" name="Fridss" id="Fri" class="open_hours" placeholder="--:--" required tabindex="16"> -
  <input type="text" name="Fridss" id="Friday" class="open_hours" placeholder="--:--" required tabindex="17">
</li>
li {
  width: 400px;
  border-bottom: 1px dotted #58585b;
}

I used your code, removed all extra tags (to my mind) and created JSFiddle-example with your code

like image 23
Igor Ivancha Avatar answered Oct 25 '25 12:10

Igor Ivancha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!