I can't get the result a paragraph in html and css.
I'd like to set 2 lines (or 2 borders) between a text, like this:
---- TEXT ----
How can I do this using CSS or something like that?
I can't get the result a paragraph in html and css.
I'd like to set 2 lines (or 2 borders) between a text, like this:
---- TEXT ----
How can I do this using CSS or something like that?
Here's a quick and easy way, so long as your background is a solid color.
HTML:
<p class="myCopy">
<span>My Text goes here</span>
</p>
CSS:
.myCopy {
display: block;
height: 10px;
border-bottom: solid 1px #000;
text-align: center;
}
.myCopy span {
display: inline-block;
background-color: #fff;
padding: 0 10px;
}
Adjust the height value of .myCopy to move the line up and down. Change the background color of the inner span to match the primary background color.
EDIT: here's a fiddle - FIDDLE!!!
From the top answer of CSS Title with Horizontal Line on either side
How about this:
<h1 class='strikearound'>Lined Title</h1>
h1.strikearound {
position: relative;
font-size: 30px;
z-index: 1;
overflow: hidden;
text-align: center;
}
h1.strikearound:before, h1.strikearound:after {
position: absolute;
top: 51%;
overflow: hidden;
width: 50%;
height: 1px;
content: '\a0';
background-color: grey;
}
h1.strikearound:before {
margin-left: -50%;
text-align: right;
}
What's nice is it doesn't rely on any particular background color
Screenshot:
You can use a paragraph <p>
or a line-break <br>
tag to separate text.
Additionally, a horizontal rule <hr>
tag will create a horizontal line to separate text.
You can use position: relative
to move children on bottom border for solid color.
Html:
<p class="myCopy">
<span>My Text goes here</span>
</p>
Css:
.myCopy {
display: block;
border-bottom: solid 1px #000;
text-align: center;
}
.myCopy span {
position:relative;
bottom: -10px;
display: inline-block;
background-color: #fff;
padding: 0 10px;
}
Styled version: http://jsfiddle.net/UnG4T/1/
Or you can use 100% width :after
and :before
with negative margin for other bg
.myCopy {
position: relative;
display: block;
text-align: center;
}
.myCopy::before, .myCopy::after{
content: "";
position: absolute;
top: 50%;
display: inline-block;
width: 100%;
border-bottom: solid 1px #000;
}
.myCopy::before{
margin-left: -100%;
}
.myCopy span {
display: inline-block;
padding: 0 10px;
}
Styled version: http://jsfiddle.net/UnG4T/3/
. A big
with a text in the middle. – Vinicius Lima Jul 07 '14 at 18:52