2013-07-28 80 views
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; 
} 

网站here

我想要做的就是有块引用适应屏幕。目前,它这样做时,页面的宽度改变:

enter image description here

当我想它这样做:

enter image description here

+1

可以定义*不工作?* –

+0

你想干什么你的媒体查询呢? – Danield

+0

@Danield更新了问题。 – Michael

回答

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 */ 
} 

注意:如果你只在你粘贴 这里,比我想告诉你,你是不是关闭 媒体查询框媒体查询样式。

Demo

+0

没有工作。我在哪里关闭街区出错? – Michael

+0

@Michael等一下,我会给你演示 –

+0

@Michael分享演示,调整小提琴窗口 –