Block quote left border same height as text

4.6k views Asked by At

How can I make a block quote line the exact same height as the text that's inside the element.

Here is an example of what It should look like:

enter image description here

This is the current result that I'm getting from the code that I have created:

blockquote {
  margin: 20px 0 30px;
  padding-left: 20px;
  border-left: 5px solid #1371b8;
}
<blockquote>Test</blockquote>

From the result, we can see that the line Is vertically bigger than the text.

4

There are 4 answers

2
jcdenooy On BEST ANSWER

NOTE: inline-flex doesn't support older browsers: http://caniuse.com/#feat=flexbox
But it does work...

  • Added a span inside the blockquote to position it optimally; keep in mind you'll have to redo this when you change fonts or font-size!

blockquote {
  font-size: 50px;
  text-transform:uppercase;
  margin-top: 10px;
  margin-bottom: 10px;
  margin-left: 50px;
  padding-left: 15px;
  border-left: 5px solid #66e4b4;
  display:inline-flex;
} 

blockquote span {
  margin-top:-10px;
  margin-bottom:-10px;
}
  <blockquote ><span>windows to the universe</span></blockquote>

– This answer is based on the original code snippet (found below) by عارف بن الأزرق

1
Aref Ben Lazrek On

Try that

blockquote {
  font-size: 50px;
  text-transform:uppercase;
  margin-top: 10px;
  margin-bottom: 10px;
  margin-left: 50px;
  padding-left: 15px;
  border-left: 5px solid #66e4b4;
} 
  <blockquote >windows to the universe</blockquote>

0
Ptrckk On

You could use line-height. Something like this:

<style> 
.header blockquote {
margin: 20px 0 30px;
padding-left: 20px;
border-left: 5px solid #1371b8;
line-height: 25px;
}
</style>

<div class="header">
<blockquote><h1>WINDOWS TO <br />
THE UNIVERSE</h1></blockquote>
</div>
0
Ravi On

Here is the solution of blockquote line height issue. Just make the blockquote:before and add the border left and adjust with position absolute. you have done. :)

blockquote{    
    font-size: 35px;
    line-height: 52px;
    margin: 28px 0;
    overflow: hidden;
    padding: 0 0 0 26px;    
    font-weight: 100;
    color: #CC6B39;    
    position: relative;
}
blockquote:before {
    content: "";
    border-left: 6px solid #39348F;
    position: absolute;
    bottom: 14px;
    top: 13px;
    left: 0;
}
<blockquote>“Lorem Ipsum is simply dummy text of the 
printing and typesetting industry. 
Lorem Ipsum has been the industry's standard dummy 
text ever since the 1500,”</blockquote>