Solved

css @media doesnt work as needed

Posted on 2014-07-20
3
212 Views
Last Modified: 2014-07-20
.slider-container{
	 height:760px;
	 background-image:url(../imgs/slider.jpg); 
	 position:relative;
}

@media (min-width: 1629px) {
	.slider-container{
	height:100px;
	background-image:none;
	background-color: #ff0000;
	position:relative;
	}
}

Open in new window



Im using this css to change the div content on smaller screens (from an image to a solid bg color)
The website always looks the same on both the mac and the iphone.

If I go above min-width: 1300px I get the red solid background color anything below that displays the image.
The issue is the same thing happens on all size devices just the same...
0
Comment
Question by:zahimezher
3 Comments
 
LVL 28

Accepted Solution

by:
chilternPC earned 500 total points
Comment Utility
I would put the word screen after media.
also try a max-width instead of a min-width .

and try this version....


.slider-container{
       height:760px;
       background-image:url(../imgs/slider.jpg);
       position:relative;
}

@media  screen and (max-device-width: 800px)

 {
      
      .slider-container{
      height:100px;
      background-image:none;
      background-color: #ff0000;
      position:relative;
      }
}
0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
Are you sure you don't have any other css in there.
Can you link to the page or make a test page at jsfiddle.net
0
 
LVL 1

Author Closing Comment

by:zahimezher
Comment Utility
Brilliant! :D Thank you so much.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now