Can I define <anything already been> in CSS? - html

Here is my code:
.el {
padding-top: 20px;
}
#media (max-width: 979px) {
.el{
padding: <anything already been> 10px 10px 10px;
}
}
Is there something to use as <anything already been> ?
I can do that like this:
#media (max-width: 979px) {
.el{
padding-right: 10px;
padding-left: 10px;
padding-buttom: 10px;
}
}
But I just like to know is there any approach to do that in one line?

I'm going to state that no, it is not possible.
Inherit would be the sufficient replacement, but this cannot be achieved because inherit counts for all 4 properties of the shorthand. You cannot semi-overrule part of it by entering inherit randomly.
Besides, with padding, it will always be converted from padding to padding-top, padding-left etc etc. Which will (as #Pete stated) overrule the original value everytime.
You should stick with your second approach:
#media (max-width: 979px) {
.el{
padding-right: 10px;
padding-left: 10px;
padding-buttom: 10px;
}
}

Theres no way to do what you want to do. You could get something closeish with custom properties to achieve this.
For example:
.el {
--paddingTop: 20px;
padding: var(--paddingTop, 0) var(--paddingRight, 0) var(--paddingBottom, 0) var(--paddingLeft, 0);
}
#media (max-width: 979px) {
.el{
--paddingRight: 10px;
--paddingBottom: 20px;
--paddingLeft: 20px;
}
}
This would be fine to use on 1 off situations but would give you way too much overhead to want to do this everywhere imo.

Related

#media (max-width: 992px). display: block does not work

#media (max-width: 992px) {
.menu__list {
display: none;
}
.btn__menu {
display: block;
}
}
.btn__menu div {
height: 5px;
background-color: #000;
margin-bottom: 5px;
}
.btn__menu {
width: 40px;
display: none;
}
The code above writes me that I have an error in display: block;. I need the burger menu to pop up when the screen is less than 992px wide but I have nothing. Where did I go wrong?
Swap the order - your general rules will overwrite the media query rules the way it's now, since they follow * after* them. So just move the media queries to the end.

Media Query does not overwrite the css even when its after

I have taken a screenshot of it in google chrome devtools to help explain this.
I have used scss that is then ccompiled to css using Koala. The media query is after the original css meaning it should be over written, however this is not the case.
Any explanation is appreciated (I have added some code examples so you dont have to view the image)
Line 190:
#recent-users, #frequent-trees{
width: calc(50% - 80px);
padding: 0px 40px;
}
Line: 261:
#media only screen and (max-width: 600px) {
#recent-users, #frequent-trees {
width: 90%;
padding: 0px 5%;
}
}
If you look carefully the selector is:
#content #recent-users, #content #frequent-trees
You either set the same for the media query:
#media only screen and (max-width: 600px) {
#content recent-users, #content #frequent-trees {
or use !important rule to override it:
#media only screen and (max-width: 600px) {
#recent-users, #frequent-trees {
width: 90% !important;
padding: 0px 5% !important;
}
}
More info: https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity

How to add a margin between title and the price tag on mobile

I want to add a margin (a break <br>) between the title and the price tag on mobile. the website is http://www.jokerleb.com. I tried
.h3{
margin:5px;
}
// and
.tags{
margin:5px;
}
and I also tried working on other divs and media queries, nothing worked, it seems that just applying a margin won't change anything. I've been working on this super silly problem for 2 days and don't know why it's not working.
Just add media query like following to get the issue fix.
#media (max-width:400px) {
.tags {
margin-bottom: 8px; /* Added */
padding: 0;
float: right;
right: 24px;
bottom: -12px;
}
}
You are doing it in a wrong way! It's crazily floated and stuff. You might need to do this and it would work:
#media screen and (max-width: 400px) {
.post-block .post-right h3 {
max-width: 100%;
float: none;
padding-top: 40px;
}
}
Preview

what's wrong with my media CSS?

I've got this in my .css file...
#media (min-width: 576px) {
.mt-5-xs { margin-top: 5px; }
.mt-10-xs { margin-top: 10px; }
.mb-5-xs { margin-bottom: 5px; }
.mb-10-xs { margin-bottom: 10px; }
}
#media (min-width: 768px) {
.mt-5-sm { margin-top: 5px; }
.mt-10-sm { margin-top: 10px; }
.mb-5-sm { margin-bottom: 5px; }
.mb-10-sm { margin-bottom: 10px; }
}
And then this in the HTML:
<div class="mt-5-xs mt-5-sm">
<button ...></button>
</div>
However, the margin-top does not render on small screens. And when I look at the Styles in dev tools, they don't even show up. It's like the classes don't exist in the css. I know the html page has access to the overall .css file, because it's where every other class is, and they all work fine.
I'm doing something wrong, just not sure what.
Try #media only screen and (min-width: 576px).
Based on your posted codes, your HTML code has the issue not the CSS as your must add class="" attribute to your div
<div class="mt-5-xs mt-5-sm">
<button ...></button>
</div>
Update : also as already other persons mentioned, if you are checking below 576px then you should add a #media (max-width:575px) or maybe 576px too.

Bootstrap2 20px padding on both-sides of screen at 767px and below

good evening, I am using Joomla built in Bootstrap2. I am making website in full width view, the problem is below 768px 20px padding add on both sides of the screen. I have added following but its not working:
#media (max-width:767px) {
.container-fluid {
padding: 0;
}
}
Thank you for your help.
Regards,
You need to update the rule defined in the responsive-bootstrap.min.css. Code in that file is :
#media (max-width:767px) {
body{
padding-left: 20px;
padding-right: 20px;
}
}
So to make it zero you have to override that rule so replace your code with this:
#media (max-width:767px) {
body{
padding: 0px;
}
}