0

I need to get an hr element in between 2 buttons so that it is vertically centered in between them.

This is my codepen, I've been struggling to find a decent solution. Could anybody please take a quick look?

Right now they are below and above.

http://codepen.io/anon/pen/gpvwvv

<button class="left">Test</button>
<hr />
<button class="right">Test</button>
cimmanon
  • 67,211
  • 17
  • 165
  • 171
Stephan-v
  • 19,255
  • 31
  • 115
  • 201

3 Answers3

2

hr element is supposed to be used horizontally talking in semantically. Instead of hr element you can use an span element. But why do you create unnecessary element while you can make this without needing any element. You can just apply a border on button element.

example:

button.left{
    border-right: 1px solid #000;
}

Alternatively, you could set border-left for the right button too.

By the way, it's not recommend way to use still while talking in semantic. You should use div for the layout and inside that div put your button elements and apply the border on div.

Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231
2

Not sure if this was the solution that you were looking for but I made a pen with the hr 'joining the two buttons'.

The easiest way is to use absolute positioning as that allows the buttons to be dynamic, like this:

hr {
position: absolute;
  width: 100%;
  top: 0;
  z-index: -1;
}

http://codepen.io/anon/pen/xGYEyE

Hope this solves your problem!

Harvey Ball
  • 131
  • 5
  • This is what I mean yeah. It just needs a little padding so it doesn't touch the buttons completely though. Kind of like it's floating between them. Thanks for the help so far. – Stephan-v Jul 01 '15 at 14:55
0

There doesn't seem to be one. But you can do something like: <div style="border-left:1px solid #000;height:500px"></div>

guergana
  • 374
  • 5
  • 19