Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 9th Sep 2015, 06:39 PM   #1
www.schrader.co
War Room Member
 
GowebMkt's Avatar
 
Join Date: 2010
Location: Northern Michigan
Posts: 469
Thanks: 207
Thanked 29 Times in 25 Posts
Default
Stuck on using media query....
Share on: 
fb share twitter share gplus share more share

Hey Warriors,

Im trying to add a media query to my site, but it wont work.

Once the site is viewed at less than 920px the web page background image should change.

Please see my source code here: https://www.schraderwebsolutions.com/woman-beach/

Thanks!

Bret

GowebMkt is offline  
Unread 9th Sep 2015, 10:47 PM   #2
Midnight Oil Warrior
 
Join Date: 2013
Location: Bridgeport, WV.
Posts: 6,796
Thanks: 3,622
Thanked 6,636 Times in 3,502 Posts
Default
Re: Stuck on using media query....
Share on: 
fb share twitter share gplus share more share

I believe there is a few errors in your code. 2 specifically. the CSS statement below is not ended correctly, and the image file is not linked to correctly.

Code:
@media only screen and (max-width: 920px) {
            #image { 
                background-image: url(smallimage.jpg); // <-- this specifically
            } // <-- Needs a second end bracket
CORRECTED

Code:
@media only screen and (max-width: 920px) {
            #image { 
                background-image: url(smallimage.jpg); // <-- this specifically
            } 
}
The image URL should look something like this:

Code:
background-image: url('images/smallimage.jpg');







Originally Posted by GowebMkt View Post

Hey Warriors,

Im trying to add a media query to my site, but it wont work.

Once the site is viewed at less than 920px the web page background image should change.

Please see my source code here: https://www.schraderwebsolutions.com/woman-beach/

Thanks!

Bret

Success is an ACT not an idea
savidge4 is offline  
The Following User Says Thank You to savidge4 For This Useful Post:
Unread 10th Sep 2015, 05:32 AM   #3
Webmaster
 
webcosmo's Avatar
 
Join Date: 2008
Location: Boston, MA
Posts: 531
Thanks: 6
Thanked 65 Times in 58 Posts
Default
Re: Stuck on using media query....
Share on: 
fb share twitter share gplus share more share

Make sure it's not overriden by another media query.

webcosmo is offline  
Unread 10th Sep 2015, 06:43 AM   #4
www.schrader.co
War Room Member
 
GowebMkt's Avatar
 
Join Date: 2010
Location: Northern Michigan
Posts: 469
Thanks: 207
Thanked 29 Times in 25 Posts
Default
Re: Stuck on using media query....
Share on: 
fb share twitter share gplus share more share

OK...so here is my updated code....the image URL is pointing to an image that doesnt exist yet.....but it still should stop showing the orig image, right?



@media only screen and (max-width: 920px) {
#image {
background-image: url('images/smallimage.jpg');
}

}

</style>

I used this code and it still shows the orig image when I scale the browser below 920px width.

I dont see any other media queries on this page that could conflict with this.

Any ideas?

GowebMkt is offline  
Unread 10th Sep 2015, 07:14 PM   #5
Midnight Oil Warrior
 
Join Date: 2013
Location: Bridgeport, WV.
Posts: 6,796
Thanks: 3,622
Thanked 6,636 Times in 3,502 Posts
Default
Re: Stuck on using media query....
Share on: 
fb share twitter share gplus share more share

I have a site that I control for the most part how it "Breaks" and use the CSS below to control that.

Code:
@media only screen and (min-width:960px){
        /* styles for browsers larger than 960px; */
    }
    @media only screen and (min-width:1440px){
        /* styles for browsers larger than 1440px; */
    }
    @media only screen and (min-width:2000px){
        /* for sumo sized (mac) screens */
    }
    @media only screen and (max-device-width:480px){
       /* styles for mobile browsers smaller than 480px; (iPhone) */
    }
    @media only screen and (device-width:768px){
       /* default iPad screens */
    }
     @media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) {
      /* For iPad portrait layouts only */
    }

    @media only screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) {
      /* For landscape layouts only */
    }

So you will want to ensure you are using a Max and a Min width command. I am guessing right now your theme by default is breaking at 768. So introducing the break at 920 would not alter anything, because the default will override because it is greater than 768. Make sense?

Success is an ACT not an idea
savidge4 is offline  
Unread 11th Sep 2015, 01:54 AM   #6
Webmaster
 
webcosmo's Avatar
 
Join Date: 2008
Location: Boston, MA
Posts: 531
Thanks: 6
Thanked 65 Times in 58 Posts
Default
Re: Stuck on using media query....
Share on: 
fb share twitter share gplus share more share

You can try adding css background-position-x: 0px;? Would that solve your current issues?

webcosmo is offline  
Closed Thread


Bookmarks

Tags
media, query, stuck


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 04:54 PM.