<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>johna's blog</title>
<link>https://johna.compoutpost.com/</link>
<description>...mostly about web development and programming, with a little bit of anything else related to the Internet, computers and technology.</description>
<item>
<title>Full width HTML5 video without preserving the aspect ratio</title>
<link>https://johna.compoutpost.com/blog/811/full-width-html5-video-without-preserving-the-aspect-ratio/</link>
<description>I recently needed to show a video on a web page that needed to take the full width of the container (in this case, the full screen width) but keep a consistent height.&lt;br&gt;&lt;br&gt;After some research I found a Stack Overflow post that lead me to a blog post, and a comment was left with what seems to be a good solution. This blog post has since been removed so I can't reference it or credit the author.&lt;br&gt;&lt;br&gt;This works by changing a CSS transform property value when the video is loaded or the browser window resized.&lt;br&gt;&lt;br&gt;Here's the JavaScript function (jQuery required), but see the source of the working example below for how to use.&lt;br&gt;&lt;br&gt;&lt;pre&gt;function sizeVideo(video) {&lt;br&gt;	var rawWidth = $(video).prop(&quot;videoWidth&quot;);&lt;br&gt;	var rawHeight = $(video).prop(&quot;videoHeight&quot;);&lt;br&gt;	var origAspect = rawWidth / rawHeight;&lt;br&gt;	var containerWidth = $(video).width();&lt;br&gt;	var containerHeight = $(video).height();&lt;br&gt;	var targetAspect = containerWidth / containerHeight;&lt;br&gt;	var multi = (targetAspect / origAspect);&lt;br&gt;	$(video).css({&lt;br&gt;		&quot;transform&quot;: &quot;scaleX(&quot; + multi + &quot;)&quot;,&lt;br&gt;		&quot;-ms-transform&quot;: &quot;scaleX(&quot; + multi + &quot;)&quot;,&lt;br&gt;		&quot;-moz-transform&quot;: &quot;scaleX(&quot; + multi + &quot;)&quot;,&lt;br&gt;		&quot;-webkit-transform&quot;: &quot;scaleX(&quot; + multi + &quot;)&quot;,&lt;br&gt;		&quot;-o-transform&quot;: &quot;scaleX(&quot; + multi + &quot;)&quot;&lt;br&gt;	});&lt;br&gt;}&lt;/pre&gt;&lt;br&gt;&lt;br&gt;The following working example uses the basic Bootstrap 3.x template and includes necessary CSS and an example of what events to call this function in.&lt;br&gt;&lt;br&gt;&lt;a href=&quot;/blog/uploads/att811_test.html&quot; target=&quot;_blank&quot;&gt;Working example&lt;/a&gt;</description>
<comments>https://johna.compoutpost.com/blog/811/full-width-html5-video-without-preserving-the-aspect-ratio/#comments</comments>
<pubDate>2016-08-10T12:00:00+10:00</pubDate>
<category>HTML/CSS</category>
<guid>https://johna.compoutpost.com/blog/811</guid>
</item>
<item>
<title>Excellent tutorial to make DHTML windows</title>
<link>https://johna.compoutpost.com/blog/557/excellent-tutorial-to-make-dhtml-windows/</link>
<description>I found this article which looks at building dynamic DHTML windows that can appear like those on the Windows desktop and are draggable, resizable, and can be minimised and restored.&lt;br&gt;&lt;br&gt;See the sample &lt;a href=&quot;http://www.brainjar.com/dhtml/windows/demo.html&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;The full article is &lt;a href=&quot;http://www.brainjar.com/dhtml/windows/default.asp&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;br&gt;&lt;br&gt;&lt;center&gt;&lt;img alt=&quot;demo.jpg&quot; src=&quot;/blog/uploads/img557_demo.jpg&quot;&gt;&lt;/center&gt;</description>
<comments>https://johna.compoutpost.com/blog/557/excellent-tutorial-to-make-dhtml-windows/#comments</comments>
<pubDate>2011-03-06T12:00:00+10:00</pubDate>
<category>HTML/CSS</category>
<guid>https://johna.compoutpost.com/blog/557</guid>
</item>
<item>
<title>100% CSS Layout</title>
<link>https://johna.compoutpost.com/blog/397/100-css-layout/</link>
<description>I had been looking for a CSS layout that has three components - a header, footer and content area - and the following characteristics:
&lt;ul&gt;
&lt;li&gt;When the content in the content area does not fill the available window space the footer should be set to the bottom of the page.&lt;/li&gt;
&lt;li&gt;When the content overflows the footer should be positioned at the end of the document, off the screen.&lt;/li&gt;
&lt;li&gt;The content area should fill at least all remaining window space so that any object I put inside it can scale to 100% of its height.&lt;/li&gt;
&lt;li&gt;The content area should have a minimum height so that it won't look silly in a very tiny window (unlikely)&lt;/li&gt;
&lt;li&gt;If the user resizes the browser the content area should resize.&lt;/li&gt;
&lt;/ul&gt;
I couldn't find a pure CSS solution so I came up with a solution that uses CSS and JavaScript.
&lt;p&gt;
&lt;a href=&quot;/blog/uploads/att397_layout.htm&quot; target=&quot;_blank&quot;&gt;View Sample (new window)&lt;/a&gt;
&lt;p&gt;
&lt;textarea rows=20 cols=50 style=&quot;width:95%&quot;&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head&gt;
    &lt;title&gt;Untitled Page&lt;/title&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
		function maxContent(){
			var divContent = getElementDimensions(document.getElementById(&quot;content&quot;));
			var divHeader = getElementDimensions(document.getElementById(&quot;header&quot;));
			var divFooter = getElementDimensions(document.getElementById(&quot;footer&quot;));
			var remainder = document.documentElement.clientHeight - divContent.y - divFooter.height - 0
			if(remainder&lt;250){remainder=250}; //minimum height of content
			document.getElementById(&quot;content&quot;).style.height = remainder + &quot;px&quot;;
			function getElementDimensions(q){
				var offsetY=offsetX=0;
				var height=q.scrollHeight;
				var width=q.scrollWidth;
				while(q){
					offsetX+=q.offsetLeft;
					offsetY+=q.offsetTop;
					q=q.offsetParent;
				}
				return{
					&quot;x&quot;:offsetX,&quot;y&quot;:offsetY,&quot;height&quot;:height,&quot;width&quot;:width
				};
			}
		}
		window.onload = maxContent;
		window.onresize = maxContent;
    &lt;/script&gt;
    &lt;style type=&quot;text/css&quot;&gt;
		html,body {
			margin:0;
			padding:0;
		}
		div#container {
		}
		div#header {
			background-color:#fbb;
		}
		div#content {
			background-color:#bfb;
		}
		div#footer {
			background-color:#bbf;
			width:100%;
			bottom:0;
		}
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;div id=&quot;container&quot;&gt;
		&lt;div id=&quot;header&quot;&gt;
			Header
		&lt;/div&gt;
		&lt;div id=&quot;content&quot;&gt;
			&lt;table border=&quot;1&quot; height=&quot;100%&quot;&gt;
				&lt;tr&gt;
					&lt;td&gt;1&lt;/td&gt;
					&lt;td&gt;2&lt;/td&gt;
					&lt;td&gt;3&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;b1&lt;/td&gt;
					&lt;td&gt;b2&lt;/td&gt;
					&lt;td&gt;b3&lt;/td&gt;
				&lt;/tr&gt;
			&lt;/table&gt;
		&lt;/div&gt;

		&lt;div id=&quot;footer&quot;&gt;
			Footer
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;/textarea&gt;</description>
<comments>https://johna.compoutpost.com/blog/397/100-css-layout/#comments</comments>
<pubDate>2008-05-28T12:00:00+10:00</pubDate>
<category>HTML/CSS</category>
<guid>https://johna.compoutpost.com/blog/397</guid>
</item>
<item>
<title>Setting a Maximum Page Width Using CSS</title>
<link>https://johna.compoutpost.com/blog/348/setting-a-maximum-page-width-using-css/</link>
<description>When designing a web site one of the first decisions to make is whether to use a fixed-width, liquid or other type layout.&lt;br&gt;&lt;br&gt;Fixed-width designs are popular but have certain limitations. If you design for 800x600 your layout may look much too small at a higher resolution. If you design for 1024x768, lower resolution screens will require a horizontal scrollbar.&lt;br&gt;&lt;br&gt;Liquid designs, although not the perfect solution, have less compromises. At very low resolutions they can become very difficult to read and at very high resolutions line lengths can become very long and also difficult to read.&lt;br&gt;&lt;br&gt;A good compromise in my opinion is to use a liquid layout but set a limit to the width.&lt;br&gt;&lt;br&gt;One method of doing this reliably on popular browsers is to use the following styling:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&amp;lt;div style=&quot;max-width:1004px;width:expression(document.body.clientWidth&amp;gt;1004?'1004px':'auto')&quot;&amp;gt;&lt;/pre&gt;In this case, the maximum width is set to 1004 (for 1024x768 screen resolution less 20px for the vertical scroll bar).</description>
<comments>https://johna.compoutpost.com/blog/348/setting-a-maximum-page-width-using-css/#comments</comments>
<pubDate>2008-02-16T12:00:00+10:00</pubDate>
<category>HTML/CSS</category>
<guid>https://johna.compoutpost.com/blog/348</guid>
</item>
</channel>
</rss>
