| | #1 |
| www.schrader.co War Room Member Join Date: 2010 Location: Northern Michigan
Posts: 469
Thanks: 207
Thanked 29 Times in 25 Posts
|
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 |
| | |
| |
| | #2 | |
| Midnight Oil Warrior Join Date: 2013 Location: Bridgeport, WV.
Posts: 6,796
Thanks: 3,622
Thanked 6,636 Times in 3,502 Posts
|
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 Code: @media only screen and (max-width: 920px) {
#image {
background-image: url(smallimage.jpg); // <-- this specifically
}
} Code: background-image: url('images/smallimage.jpg');
| |
| Success is an ACT not an idea | ||
| |
| The Following User Says Thank You to savidge4 For This Useful Post: |
| | #3 |
| Webmaster Join Date: 2008 Location: Boston, MA
Posts: 531
Thanks: 6
Thanked 65 Times in 58 Posts
|
Make sure it's not overriden by another media query.
|
| | |
| |
| | #4 |
| www.schrader.co War Room Member Join Date: 2010 Location: Northern Michigan
Posts: 469
Thanks: 207
Thanked 29 Times in 25 Posts
|
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? |
| | |
| |
| | #5 |
| Midnight Oil Warrior Join Date: 2013 Location: Bridgeport, WV.
Posts: 6,796
Thanks: 3,622
Thanked 6,636 Times in 3,502 Posts
|
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 | |
| |
| | #6 |
| Webmaster Join Date: 2008 Location: Boston, MA
Posts: 531
Thanks: 6
Thanked 65 Times in 58 Posts
|
You can try adding css background-position-x: 0px;? Would that solve your current issues?
|
| | |
| |
|
| Bookmarks |
| Tags |
| media, query, stuck |
| |