Change CSS class depending on div size [duplicate] - html

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.

Related

Fixed width not being inherited by child elements [duplicate]

This question already has answers here:
How to keep website width fixed (irrespective of screen size)
(4 answers)
Closed 6 months ago.
This post was edited and submitted for review 6 months ago and failed to reopen the post:
Not suitable for this site
So I’m currently working on a basic html web page that requires me to have a static layout and a fixed width of 1000px however when I do that I’m left with space on both the left and right of the page but when it’s on auto my elements such as my nav and other container elements take up the space etc take up the full width. What am I missing ??
Any help would be great! Thanks
I didn't quite understand your question, but I think this is the solution
width:100%;
https://www.freecodecamp.org/news/html-page-width-height
As someone say in the commants, your page is not always x pixel size so It's hard to do but you can still do something like :
body {
width: 1000px;
height: 500px;
}
But the things is that some people have a small screen so they will have a scrollbar or maybe you can use a lot of Breakpoint

CSS Text taking maximum size without wrapping or going out of the screen [duplicate]

This question already has answers here:
HTML / CSS - adjust font-size to fill parent height and width
(5 answers)
Closed 6 years ago.
What I need is the text to apear in its maximum size, withiut wrapping or going outside of the screen. I've tried with #media and changing the font-size, but this got too complicated! What I am trying to achieve is, making the faces at example.com appear at their maximum font-size even on mobile devices. The idea here is to not use media queries...
Thry the snippet to view iframe
iframe {
width: 100%;
height: 100vh;
border: none;
}
<iframe src="https://www.example.com/404.shtml">Your browser doesn't support iframes</iframe>
my initial though would be to use the vw property for the font-size. I have created this fiddle to demonstrate how it works. Resize the render screen to see how the font shrinks as the window gets smaller and grows and it gets bigger. You can use media queries to determine the max font size.
For the no-wrapping just add white-space: nowrap; in your css.

Width in HTML using px and percent [duplicate]

This question already has answers here:
How to perform arithmetic operations in CSS?
(3 answers)
Closed 6 years ago.
I have two tables that one in the right side's width is fixed and it is width: 470px. And another one is the rest of the window width. May problem is that if there is a method that one table width is dynamic and with shrinking the window the width of table in right-hand-side is something like:
width:(100% - 470px)
it means window width minus the fixed width of the second table is for the first table.
You need calc.
width: calc(100% - 470px)

Css % with height [duplicate]

This question already has answers here:
Css height in percent not working [duplicate]
(8 answers)
Closed 6 years ago.
Here is the example i'm testing on :
Bootstrap starter theme
You can try with inspect element.
Why cant i change height of header tag or the background image of it with %?
I have tried using px and it works like that.For example height:800px;
But if i use height:80%; it wont work. Can someone explain how this works ? I don't know what am i doing wrong.
When you are giving height is % value its reffere also to parent of this element. If you want to force header to have 80 % of screen height you have to take it out of the DOM flow by setting it as position:absolute.
So css can look like this :
.header-image {
position: absolute;
height: 80%;
}

Fixed navbar only on desktops? [duplicate]

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;
}
}