Fixed navbar only on desktops? [duplicate] - html

This question already has an answer here:
Apply different CSS stylesheet depending on browser window size - I can't find anything definitive
(1 answer)
Closed 8 years ago.
What is the best solution to make top navbar fixed only on large displays (desktops/tablets)?

Just use media queries for applying the rule only in monitors (only screen) above a minimum size:
#media only screen and (min-device-width: 768px){
.navbar{ // navbar class
position:fixed;
}
}

Related

How to code having in mind the screen resolution of each user? [duplicate]

This question already has answers here:
Media Queries: How to target desktop, tablet, and mobile?
(22 answers)
Closed 1 year ago.
I made my web design in Figma setting it to 1440px x 1024px.
(here is the link if that helps to see what I mean https://www.figma.com/file/IlSDcBbvr4nFp83p0jtndR/Bohhi-Portfolio?node-id=2%3A2)
Now that I want to code and style it I'm confused about it.
How can I position my objects in relation to the design and screen resolution of my PC and every other user?
Can I make it so that the code fits the design?
Thank you!
Try checking out #media query for creating responsive layouts:
https://www.w3schools.com/css/css_rwd_mediaqueries.asp
Explanation Edit:
#media only screen and (max-width: 768px) {
width: 100%;
}
For example, you can use it to ajust your preferred lyaout on devices with different screen widths (Example: Phone).
When a condition is true (Example: device screen is maximally 768px width) the following css property will be used (Example: width: 100%;). In this way you can create different content layouts and properties for PC users and Phone users.

Change CSS only for mobile devices? [duplicate]

This question already has answers here:
Responsive css styles on mobile devices ONLY
(4 answers)
Closed 5 years ago.
I just finished creating my website but now I have found a failure. My problem is that my website looks totally nice on the PC. But if I go and look at it from my mobile phone, the spaces between certain images etc. are a great deal too much...
So my question is, how can I create some CSS codes who are only affecting the mobile devices and maybe tablets?
Is there a way?
CSS has feature called media queries.
From the MDN link:
Media queries, added inĀ CSS3, let the presentation of content be tailored to a specific range of output devices without having to change the content itself
For example:
div {
background: black;
}
#media (max-width: 1000px) {
div {
background: yellow;
}
}
The background color of this div will be yellow on screen under 1000px width like in the example provided.
You can use media-queries for different screen resolutions.
Example:
#image img {
width:375px;
}
#media screen and (min-width: 1366px) {
#image img {width:375px;}
}
Read and understand about Media Queries
You will be able to adjust the css of certain media sizes of your website.

A way to only use a CSS class on non mobile devices [duplicate]

This question already has answers here:
Media Queries: How to target desktop, tablet, and mobile?
(22 answers)
Closed 7 years ago.
So, I need a way to so that a CSS class is only used by desktops (Normal Screen).
Eg:
.class {
position: fixed;
}
Is only used on desktops.
Although it's not desktop specific, you can limit it to the screen based on the screen size with a media rule around it, like so:
#media screen and (min-width: 640px) {
.class {
position: fixed;
}
}
This would limit your rule to only be applied if the monitor was at least 640 pixels wide, larger than a smartphone (today, anyway).

Change CSS class depending on div size [duplicate]

This question already has answers here:
Can media queries resize based on a div element instead of the screen?
(11 answers)
Closed 7 years ago.
So with #media screen - you are able to change CSS depending on screen size. I am looking for a way to change the CSS according to Div size
So if
#menu-logo is > 250px {
do this
} or else {
do that
}
Is there any way to do this with CSS ? I'm trying to make my website responsive. Thanks
You can check with regular media-queries at what point your div will be greater then 250px and just use that value in your media-query. Targeting the div itself will need jQuery though.

How to make bootstrap 3 unresponsive? [duplicate]

This question already has answers here:
How to remove responsive features in Twitter Bootstrap 3?
(8 answers)
Closed 8 years ago.
I have made a website with bootstrap 3, so by default it's responsive. However, I don't want it to be responsive (it's long story).
Basically I just want it so that on tablets and phones you have to zoom in and out to read it. It's just a basic brochure website which is why responsiveness isn't necessary.
I've tried taking out the meta view-port tags and googled how to do it endless times but I can't make it to act/look like a normal website, if that makes sense. What do I need to do to make Bootstrap 3 unresponsive?
.Container{width: 960px;} // add your designed width
#media (min-width: 768px){
.Container{width: 960px;}// add your designed width
}
#media (min-width: 992px){
.Container{width: 960px;}// add your designed width
}
#media (min-width: 1200px){
.Container{width: 960px;}// add your designed width
}
Write it your external CSS file. Remember First add bootstrap.css then add your external.css.