Good guide for dynamically resizing content

Soldato
Joined
27 Dec 2005
Posts
17,296
Location
Bristol
Does anyone know of a good guide that details how to dynamically resize content and various examples? I'm not the best at Javascript; I can amend but not write from scratch.

And by dynamically resizing content YouTube is probably a fine example. So depending on the browser width resizing elements, removing them or changing them (for example the logo changing to a smaller version etc). The normal use is a full written nav turning into a 3-bar nav icon too.

Thanks in advance.
 
Soldato
OP
Joined
27 Dec 2005
Posts
17,296
Location
Bristol
Gotcha. All over the CSS media queries now. I've used them before, BUT I didn't know about calc() which is useful.

One thing I'm really struggling with is displaying a YouTube video that scales whilst retaining its width:height ratio, and without cropping or going beyond the width/height of the screen.

Any ideas?!

Edit: That probably makes little sense, but for example with this code:

Code:
.videowrapper {
	position: relative;
	padding-bottom: 56.25%;
	padding-top: 25px;
	height: 0;
	margin-top:80px;
}
.videowrapper iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
}

...when full width, the video height extends beyond the bottom of the viewport height. I want it to go as wide or as high as possible but without going off the bottom and retaining the ratio.
 
Last edited:
Soldato
OP
Joined
27 Dec 2005
Posts
17,296
Location
Bristol
No, I'm obviously not explaining myself very well :D.

8tXiv0K.jpg.png

The grey is the browser viewport, the red is the video. The top one, at full width the video extends off the bottom of the browser, whereas I'd want it to be limited by the height as per the bottom example.
 
Back
Top Bottom