This is a really low effort question, as it shows you didn’t do your research on the question at all.
A very basic concept of CSS is the Cascade, it’s literally right in the name.
This means that rules defined lower in the document overwrite rules earlier in the document.
Instead of using !important, which is very bad practice, simply move the @media rule all the way down your document so it doesn’t get overridden.
Solution 2 :
Ahh I see the problem here.
The way that the code is translated in any programming language is from left to right and downwards.
so instead of using !important to avoid overriding the line(s) of code(s) and/or functions. Simply move the @media to the bottom. That way the @media will be the last function/line to be translated and wont get overridden by the the lines/functions/codes before it.
Problem :
CSS doesn’t work on other codes (width, etc.) unless !important is used, but other codes work. Why is that/what is the cause? And are there any solution besides using !important?
I have used @media on other pixels but it is working fine on all the codes except this one.
Width doesn’t change in a media query rest of the properties change.
if important works then there one more css overload your css. !important makes that it doesn’t control order direct accept that css, When you look at element from developer console. you can see what css code overload it
Comment posted by Newt Lerner
how can I solve that in any way? @pc_coder
Comment posted by mr. pc_coder
@Din Domino order of css is very important.last css code is always accepted if there is no !important code or not written in html or javascript code. You should put your css code in correct order.Put media queries to bottom because medai queries’ aim is changing default ones due to screen size. Then default ones are always be at top. As a guideline to find problem part is to use developer console. You can see there which codes are accepted,which codes are not accepted
Comment posted by Newt Lerner
@pc_coder thanks. I also found another way to solve it. I was using an external style.css before then I tried putting the other overriden styles inside the html file and it works
Comment posted by Newt Lerner
yes, thank you. I’m just starting to learn html and css in almost 2 weeks, so I made my own project where I can fiddle with my work on while taking short online courses
Comment posted by Zimri Leijen
I understand, but stackoverflow isn’t really designed to answer questions you could easily find the answer to by following basic tutorials.