CSS styling, header and footer resolution dependent - css

CSS style
is it possible to do the header and the footer contents can be depend on the resolution of a screen??
I plan for the home to be 100% size of the screen but I don't know if the contents can be resized if they resolution is big or small from the default ,especially divs and texts.. what would be the best css code that could make out the same effect, that will also be IE friendly.

is it possible to do the header and the footer contents can be depend on the resolution of a screen??
--Yes, use media queries in css to hide and show divs with separate content at different screen sizes
.header2 {
display: none;
}
#media (max-width: 600px) {
.header1 {
display: none;
}
.header2 {
display: block;
}
}

Related

Set content's as container

Is it possible to set width this same like container in css? OK, I'll display you my problem. I want to make side responsive menu which will be hide in mobile and visible on Desktop. So, I want to main content (on mobile) have width like their container and I will use translate in order to hide menu. For example
.container{
display: flex;
transform: translateX(-150px);
}
.menu {
width: 150px;
}
.content {
width: 100%;
}
I know that in JS it's possible to check container with and change .content width dinamically but I want to know that is better way to realize that.
You can use media queries to change the with dynamically based on screen size.
Here is the documentation on MDN, but probably something like this:
#media (max-width: 500px) {
/* Here are styles for screens equal to or narrower than 500px */
}

How do I make the sidebar not scrollable and fixed

I can’t for the life of me figure out how to make the sidebar fixed so it does not move when you scroll on the entire page, on desktop.
It currently has it’s own scroll wheel for some reason and I can’t figure out which part of the css to edit.
I have a #media css element set up for 955px and greater resolutions to show the sidebar instead of the mobile menu.
Here is the website: atceg.net
And the CSS: https://atceg.net/wp-content/themes/twentyfifteen/style.css?ver=5.2.4
You have set
#media screen and (min-width: 55em) {
.sidebar {
position: fixed!important;
} }
(I would assume in your WordPress customizer)
If you set it to
#media screen and (min-width: 55em) {
.sidebar {
position: relative!important;
} }
it will stay in one place.

Image size on Read the Docs (small images width)

I'm using MkDocs to generate docs using Markdown, and the theme Read the Docs.
However, I'm having trouble getting small images from scaling up on mobile phones.
I think this is linked to the Read the Docs CSS, but I'm having trouble understanding what should I do to override the behavior of setting width:100% on small screens.
The CSS applied to a certain image on a big screen (using chrome inspection) is:
.rst-content img {
max-width: 100%;
height: auto !important;
}
img {
max-width: 100%;
height: auto;
}
But if I reduce the screen, I get this extra CSS:
#media screen and (max-width: 768px)
img {
width: 100%;
height: auto;
}
I'm able to manually set the image size, for example:
<img src="/something.png" style="width: 25px">
But I would prefer if I could create some CSS to ensure that this is applied to all images, so I don't have to add this HTML tag on the middle of the Markdown file each time I want to add a small image.
Simply modify the media query (or create a new rule with higher specificity) to set the width of the images to auto for narrow viewports:
#media screen and (max-width: 768px) {
img {
width: auto;
}
}

CSS styling when using a media query is not working as intended

This is the codepen:
https://codepen.io/GummyGod/pen/XZqbKY
That's the query i wrote:
#media screen and (max-width:500px){
.content{
display:flex;
flex-wrap:nowrap;
}
.sidebar {
order:-1;
}
.resume {
width:100%;
order:;
}
}
Basically,at the end of the css file i made a css media query in order to make it responsive at widths from 0 to 500px ,however, when the size is in that range of pixels that weird tag shows up and i can't seem to be able to style it
Try this. Remove width and float:left for sidebar,main classes. Adjust padding for space between sidebar and main class based on your need.
.sidebar, .main {
display: table-cell;
}

Media Queries Image display none, and back again

Using media queries: I can make an image disappear at or below a specified width, no problem using display: none;
The problem is figuring out how to do the opposite, like above a certain width with display: none;
(Say I want a small logo to only show up below x pixels..)
Tried inline style set to display: none; then used a query to try something like display: visible; no good.
Best I could figure was a hack around, initial width and height:0 then use the query to reset the width and height at say, max-width:650px
I played with min-width and max-width I'm doing something wrong, is there an OPPOSITE to display: none; couldn't get min-width to do the opposite of max-width.
You just need to set display:none/block the img according to your needs
As I'm not sure what you really want here is 2 snippets:
snippet with image showing only above 650px
img {
display: block
}
#media (max-width: 650px) {
img {
display: none
}
}
<img src="//placehold.it/600x600" />
snippet with image showing only below 650px
img {
display: block
}
#media (min-width: 650px) {
img {
display: none
}
}
<img src="//placehold.it/600x600" />
Note: display:visible doesn't exist

Resources