I have a line of objects/elements like this:
I want to create a line, and place it behind all my objects, in the center if my div.
Here is what I'm hoping to make:
To create a border on top, right, bottom, left, or around a div is quite simple, but in the middle of the div is surprisingly hard. I've been trying to research on this, but I don't see any good one so far.
Any CSS expert want to show off your CSS skill?
Fiddle
You can do this by setting the display property to "flex." Then define the align-items and justify-content property to “center.” This will tell the browser to center the flex item (the div within the div) vertically and horizontally.
You can use: border-style: solid; border-width: thin; border-color: #FFFFFF; You can change these as you see fit, though.
Its simple to add a horizontal line in your markup, just add: <hr>. Browsers draw a line across the entire width of the container, which can be the entire body or a child element.
Here is your own updated JSFiddle
.border-center {
width: 100%;
border: red 1px solid;
position: relative;
}
.border-center:before { content: '';
position: absolute;
bottom: 50%;
border-bottom: 2px green solid;
width: 100%;
z-index:0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With