0

有人可以告诉我如何在我的网站上创建一个居中和响应式的报价,这样当浏览器窗口保持居中时它会变得更小,而且它也是居中的,只是在移动设备上更小。

谢谢

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

4 回答 4

1

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

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>

于 2015-03-26T11:54:28.810 回答
0

由于blockquote是,inline-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>

于 2015-03-26T11:09:20.000 回答
0

简单的。

blockquote{
    width:50%;
}
于 2015-03-26T11:11:01.590 回答
0
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;
    }
}
于 2015-03-26T11:11:46.523 回答