1

尝试应用一些媒体查询。

没有媒体查询的 CSS

blockquote {
margin: 1.5em 0;
font-family: 'Gentium Basic', Georgia, serif;
font-size: 20px;
line-height: 1.6em;
font-weight: normal;
font-style: italic;
border-left: 1px dotted;
padding: 0 0 0 25px;
left: 50%;
margin-left: -150px;
width: 650px;
}

然后申请:

/* larger than 800px */
@media only screen and (min-width: 801px) {
  #mobileNav {
    height: 0 !important;
  }
}
/* 800px and smaller */
@media only screen and (max-width: 800px) {
  #bannerImage {
    background-attachment: scroll !important;
  }

blockquote {
margin: 1.5em 0;
font-family: 'Gentium Basic', Georgia, serif;
font-size: 20px;
line-height: 1.6em;
font-weight: normal;
font-style: italic;
border-left: 1px dotted;
padding: 0 0 0 25px;
}

网站在这里

我想要做的是让块引用适合屏幕。目前,当页面的宽度发生变化时,它会这样做:

在此处输入图像描述

当我希望它这样做时:

在此处输入图像描述

4

1 回答 1

3

如果您没有width在媒体查询中定义 ,它将只使用width通用样式表中定义的(在本例中为650px),因此您需要width在媒体查询规则块中再次定义。

@media only screen and (max-width: 800px) {
    blockquote {
       margin: 1.5em 0;
       font-family: 'Gentium Basic', Georgia, serif;
       font-size: 20px;
       line-height: 1.6em;
       font-weight: normal;
       font-style: italic;
       border-left: 1px dotted;
       padding: 0 0 0 25px;
       width: 100%; /* Specify some width here */
       /* You should use auto value as you are using margins and paddings */
    }

    /* Other styles goes here */
}

注意:如果您在此处粘贴的媒体查询中只有样式,那么我想通知您,您没有关闭媒体查询块。

演示

于 2013-07-28T11:45:53.580 回答