我正在尝试设置我的块引号的样式,以便将它们从常规文本中删除,并使用不同的颜色背景。我发现让它们从常规文本中脱颖而出的最好方法是使用float:right,然而,我不希望块引号被强制放在段落的右侧(理想情况下,我希望它居中)。我怎样才能达到这个效果呢?
为了清楚起见,我希望块引号内的文本保持左对齐。区块引用的整个形式就是我希望居中的部分。
jsfiddle
.blockquote {
width: 75%;
float: right;
margin-top:20px;
margin-bottom: 20px;
padding: 20px;
background: #0fddaf;
background: rgb(15, 221, 175); /* Fall-back for browsers that don't support rgba */
background: rgba(15, 221, 175, .15);
font-family: fanwood_italic-webfont;
}
.blockquote p {
padding: 10px
}
<span class="blockquote">Being good in business is the most fascinating kind of art. Making money is art and working is art and good business is the best art.</span>发布于 2013-02-28 06:35:26
为什么不将.blockquote设置为display: block并删除浮点数,而不是将其浮动?然后你就可以使用页边距/填充来获得你想要的内容,而不必担心内容在你身上调整大小*。
*多。
发布于 2013-02-28 06:35:43
将span更改为div。然后去掉float:right,并添加边距:0 auto;
http://jsfiddle.net/ecCCu/3
<div class="blockquote">Being good in business is the most fascinating kind of art. Making money is art and working is art and good business is the best art.</div>
.blockquote {
width: 75%;
margin: 0 auto;
margin-top:20px;
margin-bottom: 20px;
padding: 20px;
background: #0fddaf;
background: rgb(15, 221, 175); /* Fall-back for browsers that don't support rgba */
background: rgba(15, 221, 175, .15);
font-family: fanwood_italic-webfont;
}发布于 2013-02-28 06:35:14
也许这就是你想要的:
我还添加了text-align: right以防万一,因为您已经提到希望文本转到右侧,而不是整个容器/黑引号。
编辑我忘了你有float: right在里面,所以这是另一个没有它的更新:
https://stackoverflow.com/questions/15123781
复制相似问题