Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center entire blockquote [duplicate]

Tags:

html

css

Currently the text in my blockquotes are centered, but it's creating a problem when there's not a lot of text to quote and the left border ends up too far away from the text.

Example

I'd like the border to always be 5px from the text (usually centered under an image on my blog).

Is there any way to center the entire blockquote, including the left border, so it isn't stuck in one position while the text is the only thing centered?

Current CSS:

blockquote {
    max-width:390px;
    color: #5c4c40;
    text-align: center; 
    border-left: 3px solid #897860; 
    padding-left: 5px;
    margin-left: 40px; 
}
like image 970
kmxe060 Avatar asked Jun 04 '13 10:06

kmxe060


2 Answers

Add width:auto; and display:table

blockquote {
    max-width:390px;
    color: #5c4c40;
    text-align: center; 
    border-left: 3px solid #897860; 
    padding-left: 5px;
    margin:0 auto;
    background:red;
    width:auto;
    display:table
}

DEMO

like image 155
Sowmya Avatar answered Sep 20 '22 12:09

Sowmya


<center><blockquote>test test test</blockquote></center>

http://jsfiddle.net/5g0aa3ea/

like image 28
Rakka Rage Avatar answered Sep 18 '22 12:09

Rakka Rage