居中并使块引用元素响应

centering and making responsive a blockquote element

谁能告诉我如何让我在我的网站上唱的一句话既居中又响应迅速,这样它会随着浏览器 window 保持居中而变小,但也因此居中,只是在移动设备上更小。

谢谢

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

<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>

由于 blockquoteinline-block,您可以将其与父项 text-align:center 居中。

删除 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>

简单。

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;
    }
}

请查看代码片段,如果问题仍然存在,请告诉我。

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>