I can’t seem to use the !important attribute in my cpanel. Is this a common problem
For some reason, I can’t get one of my css in my desktop media query to work. My other css in that same media query is responding ok but not for the following:
div.primervideos_heading {
position: absolute;
left: 7em;
top: 56em;
font-family: 'Lobster', cursive;
font-size: 1.5em;
text-decoration: underline;
white-space: nowrap;
}
I can’t seem to use positioning at all here….
2
Answers
Try
position: relative
to the parent element.https://developer.mozilla.org/en-US/docs/Web/CSS/position#Types_of_positioning
For example:
You haven’t given us enough information to give you a definitive answer. To do so, you would also need to post the HTML upon which your CSS operates. However, I suspect Armel’s answer is on the right track: you’re trying to absolutely position your element without a containing element that has relative positioning.
Here’s an example of how to do it right:
Now, I’m going to assume that you’re having difficulty getting your absolute positioning, and think that the reason is that some other selector is overriding yours, so you’re trying to override it with the “nuclear option”:
position: absolute !important;
This is, of course, not going to help you here, as we have explained.More importantly, though, I can’t emphasize enough that it is very bad practice to use
!important
simply because you can’t figure out why your declaration (a “declaration” is a block of CSS code with a selector and some attributes) isn’t working. That habit will turn your code into a disorganized mess.The reason to use it is when you know exactly why one of your selectors is being overridden by another selector, and you aren’t able (or at least it is very awkward) to increase the specificity of your selector to override it. (If you don’t understand what I mean, google “css specificity” and look it up.) You should use
!important
rarely, if at all, and should consider it a last resort.Finally, you may not want to use absolute positioning at all. If you are trying to, say, center your text, you’re better off working with
display: flex
and letting CSS do all the positioning work.