简体   繁体   English

居中并使响应成为blockquote元素

[英]centering and making responsive a blockquote element

Can somebody please show me how to make a quote that I amu sing on my website both centered and responsive so it gets smaller as the browser window does staying centered, but also so it is centered, just smaller on mobile devices. 有人可以告诉我如何在我的网站上发表我居中和响应的报价,以便随着浏览器窗口居中而变小,而且在移动设备上居中时变小。

Thank you 谢谢

CSS CSS

 blockquote {
    color: black;
    position: relative;
    display: inline-block;
    padding: 0 5px;
    margin: 0px auto;
    left:27%;
}

blockquote p {
    margin-bottom: 5px;
}

blockquote:before,
blockquote:after {
    content: "“";
    font-size: 70px;
    font-family: "Georgia", Serif;
    color: #28B701;
    position: absolute;
    left: -30px;
    top: 5px;
}

cite {
    float: right;
    color: black;
    font-size: 12px;
    margin: 0;
    padding: 0;
}

blockquote:after {
    content: "”";
    right: -30px;
    left: auto;
}

HTML HTML

<blockquote><p style="color:#666;">Socrates said, “Know thyself.” I say, “Know thy users.” They don’t think like you do.</p><cite>- Joshua Brewer</cite></blockquote></p>

Please see snippet and let me know if issue is still there. 请查看摘要,让我知道问题是否仍然存在。

 blockquote{ display: block; max-width: 80%; position: relative; padding: 0 5px; margin: 0 auto; } blockquote:before, blockquote:after { content:"“"; font-size: 70px; font-family:"Georgia", Serif; color: #28B701; position: absolute; left: -30px; top: 5px; } blockquote:after { content:"”"; right: -30px; left: auto; } cite { float: right; color: black; font-size: 12px; margin: 0; padding: 0; } 
 <blockquote> <p style="color:#666;">Socrates said, “Know thyself.” I say, “Know thy users.” They don't think like you do.</p> <cite>- Joshua Brewer</cite> </blockquote> 

Since the blockquote is inline-block you can center it with text-align:center on the parent. 由于blockquoteinline-block您可以text-align:center置于text-align:center的父级上。

Remove the left statement as it's not required. 删除left语句,因为它不是必需的。

body {
    text-align: center;
}
blockquote {
     color: black;
     position: relative;
     display: inline-block;
     padding: 0 5px;
     margin: 0px auto;
 }

 body { text-align: center; } blockquote { color: black; position: relative; display: inline-block; padding: 0 5px; margin: 0px auto; } blockquote p { margin-bottom: 5px; } blockquote:before, blockquote:after { content: "“"; font-size: 70px; font-family: "Georgia", Serif; color: #28B701; position: absolute; left: -30px; top: 5px; } cite { float: right; color: black; font-size: 12px; margin: 0; padding: 0; } blockquote:after { content: "”"; right: -30px; left: auto; } 
 <blockquote> <p style="color:#666;">Socrates said, “Know thyself.” I say, “Know thy users.” They don't think like you do.</p><cite>- Joshua Brewer</cite> </blockquote> 

Simple. 简单。

blockquote{
    width:50%;
}
blockquote {
    width: 100%;
}

blockquote p {
    margin-bottom: 5px;
}

blockquote:before,
blockquote:after {
    content: "“";
    font-size: 70px;
    font-family: "Georgia", Serif;
    color: #28B701;
    position: absolute;
    left: -30px;
    top: 5px;
}

cite {
    float: right;
    color: black;
    font-size: 12px;
    margin: 0;
    padding: 0;
}

blockquote:after {
    content: "”";
    right: -30px;
    left: auto;
}

@media only screen and (min-width:768px) {
    blockquote {
        width: 500px;
        margin: 0 auto;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM