<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>CSS Archives - rweber.net</title>
	<atom:link href="https://www.rweber.net/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.rweber.net/category/css/</link>
	<description>trying to be a mile wide AND a mile deep</description>
	<lastBuildDate>Sun, 09 Dec 2018 12:47:33 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">37896774</site>	<item>
		<title>Playing odd-browser-out</title>
		<link>https://www.rweber.net/css/playing-odd-browser/</link>
					<comments>https://www.rweber.net/css/playing-odd-browser/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 16 Oct 2017 12:00:01 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[website layout]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=40090</guid>

					<description><![CDATA[<div><img width="300" height="200" src="https://www.rweber.net/wp-content/uploads/2017/09/geese-1829941_640-300x200.jpg" class="attachment-medium size-medium wp-post-image" alt="Photo of five waterfowl by Luzap on Pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" fetchpriority="high" srcset="https://www.rweber.net/wp-content/uploads/2017/09/geese-1829941_640-300x200.jpg 300w, https://www.rweber.net/wp-content/uploads/2017/09/geese-1829941_640-150x100.jpg 150w, https://www.rweber.net/wp-content/uploads/2017/09/geese-1829941_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /></div>
<p>Different browsers act differently with regards to both CSS and JS, but sometimes most are in agreement and one sticks out. Here are a few examples I've come across that stood out.</p>
<p>The post <a href="https://www.rweber.net/css/playing-odd-browser/">Playing odd-browser-out</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="200" src="https://www.rweber.net/wp-content/uploads/2017/09/geese-1829941_640-300x200.jpg" class="attachment-medium size-medium wp-post-image" alt="Photo of five waterfowl by Luzap on Pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" srcset="https://www.rweber.net/wp-content/uploads/2017/09/geese-1829941_640-300x200.jpg 300w, https://www.rweber.net/wp-content/uploads/2017/09/geese-1829941_640-150x100.jpg 150w, https://www.rweber.net/wp-content/uploads/2017/09/geese-1829941_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /></div><p>&#8220;Cross-browser compatibility&#8221; is a term for a reason; different browsers act differently in both styling and function. Starting out I had in my mind that Internet Explorer was the pain in the neck, but once you get to version 10 that&#8217;s not true. Here are a few things I&#8217;ve run across where one browser (or OS, in one case) does things differently &#8211; annoyingly so &#8211; from everyone else.</p>
<h3>1. Firefox and ordered lists</h3>
<p>We wanted numbered list elements with block-displayed links inside, as the Q of an FAQ. The calculation of 100% width for the block element in FF didn&#8217;t allow room for the item numbers &#8211; unlike in Safari, Chrome, and IE/Edge &#8211; so we had unwanted line breaks. There was no cross-browser-compatible way to reduce the width, say, and still get the clean look we wanted (with expansion carets aligned at the right end of each line). Ultimately we took off the built-in numbers and added our own to the links as pseudoelements. Silly.</p>
<h3>2. iOS Safari and click handlers</h3>
<p>This one I am surprised I did not learn about earlier. Anything that is not natively clickable (buttons and links) cannot be made clickable (tappable) in Safari on iOS without shenanigans. I read a number of things that talked about it being an event bubbling problem, but attaching the handler directly to the element involved didn&#8217;t fix anything; neither did setting <code>cursor: pointer;</code> in the CSS, another trick I read about. Ultimately I had to add <code>onclick="void(0)"</code> as an attribute to the elements I wanted clickable.</p>
<h3>3. Windows and font height</h3>
<p>This one&#8217;s not browser-based &#8211; you can use Chrome on different OSes and get different results. Windows and Mac don&#8217;t approach font height the same way, and unless the vertical metrics of your font cause the calculations to agree, vertical alignment across browsers may be impossible without JavaScript. The JavaScript in question is adding a class based on the User Agent:</p>
<p><code>var usrAgt = window.navigator.userAgent;<br />
if (usrAgt.indexOf("Windows") > -1) {<br />
    // add a class to style on Windows differently from Mac, Android, iOS<br />
}</code></p>
<p>Android and iOS seem to vertically align things in agreement with Mac. I was a sad panda to have to do OS sniffing, but boy was it ugly without.</p>
<h3>4. Safari and animation trailers</h3>
<p>Safari still has a nice CSS animation repainting bug that was supposedly fixed several versions ago &#8211; it may leave a little trail of the back edge of your moving element. Setting <code>outline: 1px solid transparent;</code> on the moving element will force repainting to happen on a broad-enough area to fix that.</p>
<h3>5. Actually Safari, you&#8217;re kind of a pain</h3>
<p>Positioning defaults for Safari are apparently different from other browsers; if you absolutely position an item you&#8217;d better explicitly relatively position its container. Inline-block items are not necessarily in line with their predecessors on the line, either &#8211; I had an inline-block element after a block element (that didn&#8217;t fill the width of the container), and the inline-block&#8217;s top was aligned to the block&#8217;s bottom until I set <code>vertical-align: top;</code> on it. No positioning or alignment changes were necessary to make things show up correctly in other browsers.</p>
<hr>
<p><small>Photo by <a href="https://pixabay.com/en/geese-swimming-ocean-sea-nature-1829941/">Luzap via Pizabay</a>.</small></p>
<p>The post <a href="https://www.rweber.net/css/playing-odd-browser/">Playing odd-browser-out</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/css/playing-odd-browser/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">40090</post-id>	</item>
		<item>
		<title>Improving Embedded Google Maps</title>
		<link>https://www.rweber.net/css/improving-embedded-google-maps/</link>
					<comments>https://www.rweber.net/css/improving-embedded-google-maps/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 08 Aug 2016 12:00:17 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[cross-site interaction]]></category>
		<category><![CDATA[UX]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39944</guid>

					<description><![CDATA[<div><img width="300" height="227" src="https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640-300x227.jpg" class="attachment-medium size-medium wp-post-image" alt="vintage map collage via ArtsyBee on Pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" srcset="https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640-300x227.jpg 300w, https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640-150x113.jpg 150w, https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /></div>
<p>A simple addition to an embedded Google map greatly enhances the user-friendliness: a transparent overlay that disappears with a click.</p>
<p>The post <a href="https://www.rweber.net/css/improving-embedded-google-maps/">Improving Embedded Google Maps</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="227" src="https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640-300x227.jpg" class="attachment-medium size-medium wp-post-image" alt="vintage map collage via ArtsyBee on Pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640-300x227.jpg 300w, https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640-150x113.jpg 150w, https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640.jpg 640w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>If you embed a Google map into your page via Google&#8217;s embed code, you can set a location marker and a zoom level (on the Google Maps side, before you click the &#8220;share&#8221; button), but other tweaks are reserved for users with API accounts. I was recently in a situation where we simply wanted to disable scroll-to-zoom, because it is super annoying &#8211; especially on mobile.</p>
<p>Somewhere online I found the idea to cover the map with a transparent div (you can see through it, but you can&#8217;t click through it or &#8220;scroll through&#8221; it) and add a line of JavaScript to remove that div if it is clicked on. It seemed hacky to me at first but the more I thought about it the more I liked it. We decided to use it and not even to worry about putting a &#8220;click to interact&#8221;-type note. If someone clicks once without effect they are going to click again, and then what they wanted to do will work.</p>
<style>
.iframe-wrapper {
max-width: 600px;
margin: 24px auto;
}
.iframe-sizer {
position: relative;
width: 100%;
height: 0;
padding-bottom: 75%;
}
.responsive-iframe, .iframe-shield {
position: absolute;
height: 100%;
width: 100%;
top: 0;
left: 0;
}
</style>
<div class="iframe-wrapper">
<div class="iframe-sizer">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d8169323.504260123!2d177.63283954121277!3d-1.2107823671053861!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x7aa74442cdcc4813%3A0x1ca1ca257cc16b66!2sBaker+Island!5e0!3m2!1sen!2sus!4v1470480524869" frameborder="0" style="border:0" allowfullscreen class="responsive-iframe"></iframe></p>
<div class="iframe-shield" id="iframe-shield"></div>
</div>
</div>
<p><script>
document.getElementById("iframe-shield").addEventListener("click", function() {
    this.setAttribute("style", "height:0;");
});
</script></p>
<p>If you are setting up your maps in a <a href="https://www.rweber.net/web-development/css/responsive-iframes/">responsive iframe wrapper</a>, the setup is very simple. Just tuck a second div in after the iframe (second so it will be on top), give it the same styling as the iframe, and add a line of JavaScript in the footer of your page.</p>
<p>Here&#8217;s the code for the embedded map above (<a href="http://pastebin.com/JApYCHTX">view on pastebin</a>):</p>
<p><script src="//pastebin.com/embed_js/JApYCHTX"></script></p>
<p>The post <a href="https://www.rweber.net/css/improving-embedded-google-maps/">Improving Embedded Google Maps</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/css/improving-embedded-google-maps/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39944</post-id>	</item>
		<item>
		<title>Side by Side Divs</title>
		<link>https://www.rweber.net/css/side-side-divs/</link>
					<comments>https://www.rweber.net/css/side-side-divs/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 18 Jan 2016 13:00:30 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[website layout]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39220</guid>

					<description><![CDATA[<div><img width="300" height="218" src="https://www.rweber.net/wp-content/uploads/2016/01/lampion-152693_1280-300x218.png" class="attachment-medium size-medium wp-post-image" alt="illustration of hanging lamps" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/01/lampion-152693_1280-300x218.png 300w, https://www.rweber.net/wp-content/uploads/2016/01/lampion-152693_1280-768x559.png 768w, https://www.rweber.net/wp-content/uploads/2016/01/lampion-152693_1280.png 1024w, https://www.rweber.net/wp-content/uploads/2016/01/lampion-152693_1280-150x109.png 150w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>How many ways are there to position a sidebar next to the main content of the page?</p>
<p>The post <a href="https://www.rweber.net/css/side-side-divs/">Side by Side Divs</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="218" src="https://www.rweber.net/wp-content/uploads/2016/01/lampion-152693_1280-300x218.png" class="attachment-medium size-medium wp-post-image" alt="illustration of hanging lamps" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/01/lampion-152693_1280-300x218.png 300w, https://www.rweber.net/wp-content/uploads/2016/01/lampion-152693_1280-768x559.png 768w, https://www.rweber.net/wp-content/uploads/2016/01/lampion-152693_1280.png 1024w, https://www.rweber.net/wp-content/uploads/2016/01/lampion-152693_1280-150x109.png 150w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>How many ways are there to place a sidebar alongside the main content of the page, when it appears after the content in the HTML? I&#8217;m presuming here that you want a responsive design where the sidebar drops below the content at small sizes. Here are some ways to position content in a horizontal line. Possibilities 2 through 7 are illustrated <a href="https://www.rweber.net/alignment/">on a demo page</a>.</p>
<p>While working on this post I found <a href="http://blog.karenmenezes.com/2014/apr/13/floats-inline-block-or-display-table-or-flexbox/">a similar post by Karen Menezes</a> that goes into more detail on certain points.</p>
<p><strong>1. HTML tables.</strong> But don&#8217;t use these for large-scale layout. Why not? They exist separately on every page, making changing them a larger job, and responsiveness requires quashing the table&#8217;s natural (i.e. HTML) state of being. AND there are CSS tables (see below) that do the same thing more cleanly.</p>
<p><strong>2. Absolute positioning.</strong> Easy to make responsive in and of itself &#8211; just don&#8217;t apply it until the screen is wide enough &#8211; but essentially impossible to get to play nicely with any elements underneath, unless either A) you use JavaScript, or B) the height of your content and sidebar is fixed, which is hard to imagine happening in a responsive context (and certainly not if you&#8217;re using this layout for multiple pages, as with a CMS). <a href="https://www.rweber.net/alignment/?style=1">In the demo</a>, I have pushed the footer below the content at 1000px-wide screens, which you will see leads to a gap at wider screens.</p>
<p><strong>3. CSS columns.</strong> This is something of a faux answer. I really like these for columns of small elements &#8211; the widgetized area of this theme uses them &#8211; but they require your side-by-side regions be equal width (if you set a width on a div within a columnized wrapper it will be relative to one column), and they may break your content over two columns. It is unlikely this is what you want in the content-sidebar setting. They are good to know about, though I&#8217;ve learned they still need browser prefixes.</p>
<p><strong>Edit 2/23:</strong> Since this writing I&#8217;ve learned about <code>break-inside: avoid;</code>, which you can set on the elements inside the columns to prevent them from breaking across columns (see <a href="https://css-tricks.com/almanac/properties/b/break-inside/">CSS-Tricks for cross-browser syntax</a>). On the other hand, I&#8217;ve also learned that the lovely slider function Flickity doesn&#8217;t work in CSS columns.</p>
<p><strong>4. Inline-block display.</strong> If you set <code>display: inline-block;</code> on appropriate-width divs they will sit next to each other. By default they will be bottom-aligned, so you&#8217;ll probably want <code>vertical-align: top;</code> on both the sidebar and content divs. Note that <code>display: inline;</code> won&#8217;t work because width doesn&#8217;t apply to inline elements. Caveat: whitespace in markup translates to whitespace onscreen, so if you lack sufficient control over the HTML to eliminate whitespace your elements won&#8217;t touch onscreen (and hence can&#8217;t have widths summing to 100%). You can <a href="https://www.rweber.net/alignment/?style=3">try it in the demo</a>: go to your developer tools, turn off the sidebar and main content borders, and add 2% to the width of one of the pieces (currently widths and padding sum to 98%). The sidebar will pop down below the content.</p>
<p><strong>5. Floats.</strong> This is a classic solution: float the content left and the sidebar right (or both left; the effect is different when the width sum is less than 100% but the idea is the same). This works well for just the content-sidebar setup, as long as you have a wrapper div with <code>overflow: hidden;</code> set on it to push your footer down. It does not lend itself well to more complicated layouts where taking elements out of the usual document flow introduces the need for a lot of clearfixes and other extra markup to maintain the layout. </p>
<p><strong>6. CSS tables.</strong> This is the rule <code>display: table;</code> set on the wrapper and <code>display: table-cell;</code> set on the contents (there is also <code>display: table-row;</code> which could be put on an intermediate wrapper, but isn&#8217;t strictly necessary if you have only one row). It will line things up cleanly and is easily styled and made responsive. Every cell in a row will be made the same height and aligned together, which can be either overly rigid or just what you want. I think it makes the front page of this site look neater, and used it elsewhere to easily make a sidebar border into a full-height dividing line between content and sidebar. Caveats: if one side of your content is pushed down, the other will be also, unless you set <code>vertical-align: top;</code> on it &#8211; I&#8217;ve even seen an embedded Youtube video at the top of one side being interpreted as simply pushing the content down, and the other side pushing itself down to match (though not in all browsers). Also, if you want space between the borders of neighboring cells without space around the outside of the table, you&#8217;ll have to set a negative margin on the table wrapper.</p>
<p><strong>7. Flexbox.</strong> If you don&#8217;t mind having to have a separate backup layout for (older if not all versions of) IE, flexbox is another option. [This simple layout should work in 10 and 11; more complex layouts may have issues even with those.] It will also make the divs equal height by default, though I believe you can change that. The two items will have to be in whole-integer proportions, but it doesn&#8217;t have to be that one is a multiple of the other. In the demo I commented out the widths of the divs, set the content to <code>flex: 7;</code> and the sidebar to <code>flex: 3;</code> with the wrapper set to <code>display: flexbox;</code>. I haven&#8217;t worked much with flexbox but this use-case has wonderfully simple syntax. CSS-Tricks has an article on <a href="https://css-tricks.com/using-flexbox/">mixing generations of flexbox syntax for strongest-possible browser support</a>. I simply threw the most modern code into <a href="http://simevidas.jsbin.com/gufoko/quiet">Autoprefixer</a> and took what it gave me.</p>
<p>In the beautiful future we may also have a <a href="https://www.w3.org/TR/2009/WD-css3-layout-20090402/">template layout module</a> that looks really, really terrific.</p>
<p>The post <a href="https://www.rweber.net/css/side-side-divs/">Side by Side Divs</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/css/side-side-divs/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39220</post-id>	</item>
		<item>
		<title>As responsive as iframes get</title>
		<link>https://www.rweber.net/css/responsive-iframes/</link>
					<comments>https://www.rweber.net/css/responsive-iframes/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 21 Dec 2015 13:00:46 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[cross-site interaction]]></category>
		<category><![CDATA[website layout]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39261</guid>

					<description><![CDATA[<div><img width="207" height="300" src="https://www.rweber.net/wp-content/uploads/2015/12/Rahmen-207x300.jpg" class="attachment-medium size-medium wp-post-image" alt="Wooden Picture Frames photo by Michael Moeller" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/12/Rahmen-207x300.jpg 207w, https://www.rweber.net/wp-content/uploads/2015/12/Rahmen-104x150.jpg 104w, https://www.rweber.net/wp-content/uploads/2015/12/Rahmen.jpg 671w" sizes="auto, (max-width: 207px) 100vw, 207px" /></div>
<p>Making iframed content adapt to various width displays while maintaining its aspect ratio is more complicated than one might like. However, it's not hard, and this post shows you how to do it.</p>
<p>The post <a href="https://www.rweber.net/css/responsive-iframes/">As responsive as iframes get</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="207" height="300" src="https://www.rweber.net/wp-content/uploads/2015/12/Rahmen-207x300.jpg" class="attachment-medium size-medium wp-post-image" alt="Wooden Picture Frames photo by Michael Moeller" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/12/Rahmen-207x300.jpg 207w, https://www.rweber.net/wp-content/uploads/2015/12/Rahmen-104x150.jpg 104w, https://www.rweber.net/wp-content/uploads/2015/12/Rahmen.jpg 671w" sizes="auto, (max-width: 207px) 100vw, 207px" /></div><p>The iframe is still state of the art for embedding content from a number of other webpages, but it is not a naturally responsive object. You can make it responsive, but it takes some effort. I&#8217;ve selected some Youtube videos to illustrate.</p>
<h3>Doing nothing</h3>
<p>Here is a video in standard Youtube syntax:</p>
<p><iframe loading="lazy" width="560" height="420" src="https://www.youtube.com/embed/lKaE3jWsKEw" frameborder="0" allowfullscreen></iframe></p>
<p>Since my theme gives iframes a max-width of 100%, it will narrow when you narrow the window, but it won&#8217;t change height, adding black bars above and below the content to maintain the aspect ratio of the video itself. This isn&#8217;t a big deal when the video is small, but gets more problematic when you want a larger display.</p>
<h3>Doing something worse than nothing</h3>
<p>Next we can remove the explicitly-set height and width, but that gives you this:</p>
<p><iframe src="https://www.youtube.com/embed/3PgayXQsik0" frameborder="0" allowfullscreen></iframe></p>
<p>You have to enclose the iframe in a div that adapts its size, but even that takes some effort. Here is the video where the iframe has had its height and width replaced by the tag <code>style="width: 100%;"</code>, and is enclosed in a div with <code>style="width: 600px; max-width: 100%; position: relative;"</code>.</p>
<div style="width: 600px; max-width: 100%; position: relative;"><iframe style="width: 100%;" src="https://www.youtube.com/embed/5vJRR-mU8x0" frameborder="0" allowfullscreen></iframe></div>
<p>You can make it wider or narrower by changing the width style, but it won&#8217;t get any taller.</p>
<h3>Doing enough</h3>
<p>The answer is to play the <a href="https://www.rweber.net/web-development/css/aspect-ratio/">aspect ratio trick</a> and enclose the iframe in two divs. The outer div controls the width and placement; here it&#8217;s set with <code>style="width: 100%; max-width: 700px;"</code> (700 for dramatic effect). The inner div accommodates the changing height of the box with <code>style="height: 0; padding-bottom: 56.25%; position:relative;"</code>, where the 56.25% comes from original height 315 divided by original width 560. The iframe has its height and width declarations replaced by <code>style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;"</code>. Absolute positioning allows it to take up the padding space of its container rather than just the content space (which of course is 0 because of the 0 height). The rest forces it to do so.</p>
<div style="width:100%; max-width:700px;">
<div style="height: 0; padding-bottom: 56.25%; position:relative;"><iframe style="position:absolute; width:100%; height: 100%; top:0; left:0;" src="https://www.youtube.com/embed/c0pnp4uMZFs" frameborder="0" allowfullscreen></iframe></div>
</div>
<p>All of this styling is inline, so you can see it in the source of this page.</p>
<p><small>Frames photo by Michael M&ouml;ller, via <a href="https://commons.wikimedia.org/wiki/File:Rahmen.jpg">Wikimedia Commons</a>.</small></p>
<p>The post <a href="https://www.rweber.net/css/responsive-iframes/">As responsive as iframes get</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/css/responsive-iframes/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39261</post-id>	</item>
		<item>
		<title>Mysterious Extraneous Whitespace</title>
		<link>https://www.rweber.net/css/mysterious-extraneous-whitespace/</link>
					<comments>https://www.rweber.net/css/mysterious-extraneous-whitespace/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 14 Dec 2015 13:00:33 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[website layout]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39268</guid>

					<description><![CDATA[<div><img width="300" height="225" src="https://www.rweber.net/wp-content/uploads/2015/12/mind-the-gap-882368_640-300x225.jpg" class="attachment-medium size-medium wp-post-image" alt="Mind the Gap" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/12/mind-the-gap-882368_640-300x225.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/12/mind-the-gap-882368_640-150x113.jpg 150w, https://www.rweber.net/wp-content/uploads/2015/12/mind-the-gap-882368_640.jpg 640w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>Assorted notes on recent experiences I've had with large amounts of blank space in websites. For smaller amounts you can check out my much earlier post on <a href="https://www.rweber.net/web-development/css/eliminating-white-space/">eliminating white space</a>.</p>
<p>The post <a href="https://www.rweber.net/css/mysterious-extraneous-whitespace/">Mysterious Extraneous Whitespace</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="225" src="https://www.rweber.net/wp-content/uploads/2015/12/mind-the-gap-882368_640-300x225.jpg" class="attachment-medium size-medium wp-post-image" alt="Mind the Gap" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/12/mind-the-gap-882368_640-300x225.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/12/mind-the-gap-882368_640-150x113.jpg 150w, https://www.rweber.net/wp-content/uploads/2015/12/mind-the-gap-882368_640.jpg 640w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>Assorted notes on recent experiences I&#8217;ve had with large amounts of blank space in websites. For smaller amounts you can check out my much earlier post on <a href="https://www.rweber.net/web-development/css/eliminating-white-space/">eliminating white space</a>.</p>
<p>1.) On one site I set <code>display: table</code> on the content and sidebar so they would always be the same height. Later we made a page on which the page title was hidden and the first element in the content was an embedded video (wrapped in a couple of divs to allow responsiveness). In Chrome and Firefox that was fine; in Safari and IE the sidebar was pushed down. Safari&#8217;s developer tools showed it as padding, but far more than the pixel value listed. I realized the title of the first sidebar widget was lined up with the line of text under the video in all cases, from which I diagnosed that the browser was interpreting that line of text as the first thing in the cell. Setting <code>vertical-align: top</code> on the sidebar cured it. (In the reverse direction, when JavaScript is inactive the sidebar has a large top margin to accommodate the click-to-show menu being always visible, and the main content needs <code>vertical-align: top</code> to be positioned correctly.)</p>
<p>2.) I used CSS columns on a widgetized area on the footer of my page and ended up with a pile of whitespace after the end of the page content. The space wasn&#8217;t associated with any particular element. It turned out the order of rendering operations led to an absolutely positioned element being placed far down the page prior to the widgets being converted to columns and hence reducing their reach. The item was a bit of screen-reader-only text for the search widget and hence was a 1&#215;1 pixel box, for all intents and purposes invisible. I found <a href="http://stackoverflow.com/questions/28598023/massive-white-space-at-bottom-of-wordpress-front-page">that exact problem on Stack Overflow</a>, which gave me the diagnosis and the fix: set <code>position: relative</code> on the widgets.</p>
<p>3.) A different set of CSS columns had some whitespace <em>above</em> certain elements. This turned out to be another <code>display: table</code> problem rather than a column problem. This time, the display was set on the <code>:before</code> pseudoelement. Underscores uses a float clearing fix involving setting <code>display: table</code> on the <code>:before</code>s of a set of classes, and in this one case it was causing extra whitespace. Changing it to <code>display: block</code> for that particular page fixed it. It is possible there would be a vertical alignment fix for this as well, but its appearance was irregular and hence hard to test with.</p>
<p>The post <a href="https://www.rweber.net/css/mysterious-extraneous-whitespace/">Mysterious Extraneous Whitespace</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/css/mysterious-extraneous-whitespace/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39268</post-id>	</item>
		<item>
		<title>Parallax without Plugins</title>
		<link>https://www.rweber.net/css/parallax-without-plugins/</link>
					<comments>https://www.rweber.net/css/parallax-without-plugins/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 16 Nov 2015 14:00:31 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[portfolio]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39226</guid>

					<description><![CDATA[<div><img width="300" height="151" src="https://www.rweber.net/wp-content/uploads/2015/11/race-801940_1280-300x151.jpg" class="attachment-medium size-medium wp-post-image" alt="photo of runners waiting to race down their lanes" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/11/race-801940_1280-300x151.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/11/race-801940_1280.jpg 1024w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>We've done some simple parallax on a couple of websites recently, using jQuery but no additional JavaScript libraries. It takes some hand-tweaking - and you have to know your items in advance - but is also much lighter weight than a plugin. Here's how.</p>
<p>The post <a href="https://www.rweber.net/css/parallax-without-plugins/">Parallax without Plugins</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="151" src="https://www.rweber.net/wp-content/uploads/2015/11/race-801940_1280-300x151.jpg" class="attachment-medium size-medium wp-post-image" alt="photo of runners waiting to race down their lanes" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/11/race-801940_1280-300x151.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/11/race-801940_1280.jpg 1024w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>We&#8217;ve done some simple parallax on a couple of websites recently, using jQuery but no additional JavaScript libraries. It takes some hand-tweaking &#8211; and you have to know your items in advance &#8211; but is also much lighter weight than a plugin.</p>
<p>The simplest version is elements scrolling independently of the page and each other, for decorative effect &#8211; so where they are when isn&#8217;t so crucial. Each needs to be fixed position and you&#8217;ll likely want some horizontal placement in the form of margins or left/right values.</p>
<p>In the JavaScript we&#8217;ll manipulate the CSS top value according to the amount we&#8217;ve scrolled the page.</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=usqDCxNi" style="border:none;width:100%;height:250px;"></iframe></p>
<p>Bind a function to the scroll event, then within that function calculate how far the page has been scrolled and use it to compute a new top value for each parallaxed element. In this case, starting 800px from the top, the element will scroll one quarter as fast as the page itself. The initial value for top in the CSS should also be 800px, or the element will jump when the page is first scrolled (if you are starting with very large &#8211; i.e. always offscreen &#8211; top values they probably don&#8217;t need to match, but there&#8217;s also no reason not to match them).</p>
<p>By changing the initial value and the multiplier to how much the page has been scrolled, you can get a variety of rates and entry points. Careful of your opacity &#8211; with abstract images, one showing through another can be lovely, but with representative images it may just be weird and distracting.</p>
<h2>Multiple Items with Coordination</h2>
<p>Since using that version of parallax I was called on to create a more complicated version. In this, we&#8217;re scrolling many items separately from the page, but certain subsets of them have to align at points along the way. This made tweaking just starting point and rate of scroll completely impractical &#8211; it would have taken forever. It also made screen height an important consideration.</p>
<p>Algebra to the rescue: All of the parallax in this post is linear; that is, the calculation of the CSS top value from the amount the page has been scrolled is the equation of a line. We can make our choice of linear equation more deliberate with two points on the line and the following equation:<br />
<img decoding="async" src="https://s0.wp.com/latex.php?latex=+y+-+y_1+%3D+%5Cfrac%7By_2+-+y_1%7D%7Bx_2+-+x_1%7D+%28x+-+x_1%29+&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt=" y - y_1 = &#92;frac{y_2 - y_1}{x_2 - x_1} (x - x_1) " class="latex" /><br />
In this case, x is the amount of scroll and y is the top value. What are the two points? I used the point where the element should touch the bottom of the screen and the point when all of a batch of elements should be in their proper relative positions. You can get some complicated arithmetic, but fortunately JavaScript knows how to do that. I ended up with a helper function:</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=wbUxmf1y" style="border:none;width:100%;height:262px;"></iframe></p>
<p>Since I had a good number of elements calling this function I expected calculating screen height once and then passing it as a function input was more efficient than calling that jQuery function repeatedly. The function above takes the inputs x<sub>1</sub>, y<sub>1</sub>, x<sub>2</sub>, y<sub>2</sub>, x, and returns y.</p>
<p>There&#8217;s more algebra to determine what the appropriate ending top value should be, dependent of course on number and desired alignment of items. I wanted three rows of items, equally spaced, with margins of 48px above, between, and below. I also wanted them to align that way when the page had been scrolled 1.25 times the screen height &#8211; they were &#8220;page two&#8221; but I needed the breathing room of that extra quarter-screen for the parallax effect.</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=fBfvu7e5" style="border:none;width:100%;height:330px;"></iframe></p>
<p>Why not 3/4 screen height on that third item? Because that gave it far too long to get to its final position, and as a result it took forever to disappear off the top of the screen &#8211; long enough to overlap with &#8220;page three,&#8221; the items lined up when we&#8217;d scrolled 2.5 times the screen height. With 7/8 screen height it still lingers, but gets out of the way in time.</p>
<p>The post <a href="https://www.rweber.net/css/parallax-without-plugins/">Parallax without Plugins</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/css/parallax-without-plugins/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39226</post-id>	</item>
		<item>
		<title>Troubleshooting Flickity: one note</title>
		<link>https://www.rweber.net/javascript/troubleshooting-flickity-one-note/</link>
					<comments>https://www.rweber.net/javascript/troubleshooting-flickity-one-note/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 24 Aug 2015 12:00:56 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Flickity]]></category>
		<category><![CDATA[images]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39155</guid>

					<description><![CDATA[<div><img width="300" height="200" src="https://www.rweber.net/wp-content/uploads/2015/08/4744428334_13c70a6165_z-300x200.jpg" class="attachment-medium size-medium wp-post-image" alt="photo of amusement park height restriction sign" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/08/4744428334_13c70a6165_z-300x200.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/08/4744428334_13c70a6165_z-150x100.jpg 150w, https://www.rweber.net/wp-content/uploads/2015/08/4744428334_13c70a6165_z.jpg 640w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>The key to Flickity is this: everything it is applied to needs to have accurate size beforehand. Here are some cases where that wasn't the case and how I fixed them.</p>
<p>The post <a href="https://www.rweber.net/javascript/troubleshooting-flickity-one-note/">Troubleshooting Flickity: one note</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="200" src="https://www.rweber.net/wp-content/uploads/2015/08/4744428334_13c70a6165_z-300x200.jpg" class="attachment-medium size-medium wp-post-image" alt="photo of amusement park height restriction sign" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/08/4744428334_13c70a6165_z-300x200.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/08/4744428334_13c70a6165_z-150x100.jpg 150w, https://www.rweber.net/wp-content/uploads/2015/08/4744428334_13c70a6165_z.jpg 640w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>Just a quick note this week. The JavaScript add-on Flickity is fun, but I don&#8217;t always get what I want from it immediately. Here&#8217;s the key I&#8217;ve deduced: everything Flickity is applied to needs to have accurate size beforehand. I&#8217;ve encountered two situations where that was not the case.</p>
<p>The first, explained in my <a href="https://www.rweber.net/web-development/css/gilding-the-gallery-mla-flickity/">MLA + Flickity post</a>, was when max-width: 100% set on images was causing anything not visible at the beginning of the slideshow to be blank &#8211; or, more accurately, zero width.</p>
<p>More recently, I was trying to create a slideshow in a page where most of the content accordion-folds up at mobile size. No applying Flickity with HTML there! If I did, I got one of two outcomes: if I set a height on my images, they all showed up stacked on top of each other. If not, the whole thing was the height of the combined top and bottom padding of the container. I needed to add a distinguishing class, and then set the accordioning code to check whether a panel it had just opened had that class. If so, apply Flickity from the JavaScript at that point. I&#8217;ve had no trouble with repeated opening and closing of the accordion.</p>
<p><strong>Edit 9/30:</strong> In fact yet a third issue has arisen: Flickity not knowing the height of the slideshow because it&#8217;s being applied before the page content is fully loaded. <code>$(document).ready</code> wasn&#8217;t enough; I needed <code>$(window).load(function () { /*call Flickity here*/ });</code><br />
[Edit 12/12/16: .load was deprecated many versions of jQuery ago and finally removed in v3. Try <code>$(window).on("load", function(){});</code>]</p>
<p><strong>Edit 2/23/16:</strong> I don&#8217;t know the reason for the conflict as of this writing, but I&#8217;ve since discovered that Flickity does not get along with CSS columns. With <code>overflow: hidden;</code> set on .flickity-viewport no images show, and with it removed, some images show outside of the viewport.</p>
<p>I hope this helps someone!</p>
<p><small>You Must Be This Tall to Ride from Eric Mesa via <a href="https://www.flickr.com/photos/ericsbinaryworld/4744428334">Flickr</a>.</small></p>
<p>The post <a href="https://www.rweber.net/javascript/troubleshooting-flickity-one-note/">Troubleshooting Flickity: one note</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/javascript/troubleshooting-flickity-one-note/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39155</post-id>	</item>
		<item>
		<title>Tweaking the simple auto-playing slideshow</title>
		<link>https://www.rweber.net/javascript/tweaking-simple-auto-playing-slideshow/</link>
					<comments>https://www.rweber.net/javascript/tweaking-simple-auto-playing-slideshow/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 10 Aug 2015 12:00:55 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[portfolio]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=38469</guid>

					<description><![CDATA[<div><img width="300" height="206" src="https://www.rweber.net/wp-content/uploads/2015/07/Projecteur_de_diapositives_Prestinox_début_des_années_1960-300x206.jpg" class="attachment-medium size-medium wp-post-image" alt="image of slide projector" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/07/Projecteur_de_diapositives_Prestinox_début_des_années_1960-300x206.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/07/Projecteur_de_diapositives_Prestinox_début_des_années_1960.jpg 752w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>Two variations on CSS-Tricks' Simple Auto-Playing Slideshow (jQuery): one to load slideshow content via AJAX, and one to turn each slideshow item into a question-answer pair.</p>
<p>The post <a href="https://www.rweber.net/javascript/tweaking-simple-auto-playing-slideshow/">Tweaking the simple auto-playing slideshow</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="206" src="https://www.rweber.net/wp-content/uploads/2015/07/Projecteur_de_diapositives_Prestinox_début_des_années_1960-300x206.jpg" class="attachment-medium size-medium wp-post-image" alt="image of slide projector" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/07/Projecteur_de_diapositives_Prestinox_début_des_années_1960-300x206.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/07/Projecteur_de_diapositives_Prestinox_début_des_années_1960.jpg 752w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>Ever since I found it probably close to a year ago, I&#8217;ve been a big fan of the <a href="https://css-tricks.com/snippets/jquery/simple-auto-playing-slideshow/">simple auto-playing slideshow on CSS-Tricks</a> (though perhaps surprisingly I have yet to apply it to a Media Library Assistant-generated WordPress gallery). I&#8217;ve tweaked it multiple times to serve different purposes, and thought I&#8217;d share two.</p>
<p>The first tweak is more of a wrapper than a modification. It has two features: it loads the slideshow content via AJAX, and it has a small change to the CSS to smooth the beginning of the slideshow.</p>
<p>I wanted to load the slideshow dynamically so I could turn it off entirely on mobile, without a Very Helpful Browser loading the images in case they were used later, slowing down the site. The page itself had the slideshow as a banner header, and it was collapsed at small sizes, so I used its height as the test in the JavaScript. There was a #slideshow div which had a background image set in CSS (via a class JavaScript removed) in case someone&#8217;s JavaScript was disabled, and the slideshow images were in a separate file as naked HTML (though the file was .php for no particular reason) to be pulled in with jQuery.load(). </p>
<p>As for the CSS, I found that trying to hide all but one image via CSS and have the JavaScript take over from there gave me a herky-jerky first transition. Instead, I hid everything in the CSS and used JavaScript to show the first image just as soon as the images were loaded up.</p>
<p>AJAXified slideshow JavaScript:</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=RtXdEw1d" style="border:none;width:100%;height:175px;"></iframe></p>
<p>This and the JavaScript below need to be wrapped in a $(document).ready(function () { &#8230; }); to operate most smoothly.</p>
<p>CSS:</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=PGNHEvtc" style="border:none;width:100%;height:250px;"></iframe></p>
<hr>
<p>The second tweak makes it a double slideshow: question and answer. In situ it uses WordPress text widgets, the title for the question and the content for its answer, but you can do it with any paired elements. The code below assumes a div with both class and id slideshow-wrapper, holding divs with class slideshow-item, each holding a pair of divs: .question and .answer. There are two different timeframes. The loop moves from pair to pair, and within it the question appears first, then the answer, they stay put for a while for reading, and then both fade away.</p>
<p>The other change to this one is that there&#8217;s a lone single animation outside the setInterval loop. Your choices without this separate bit are to have both the question and the answer in view immediately upon loading the page, or to wait with blank space for the entire first interval.</p>
<p>Q&#038;A slideshow JavaScript:</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=UKTKj68q" style="border:none;width:100%;height:250px;"></iframe></p>
<p>CSS:</p>
<p><iframe src="http://pastebin.com/embed_iframe.php?i=HYYnqgmb" style="border:none;width:100%;height:250px;"></iframe></p>
<p><small><a href="https://commons.wikimedia.org/wiki/File:Projecteur_de_diapositives_Prestinox_d%C3%A9but_des_ann%C3%A9es_1960.jpg">Slide projector image by Jean-Jacques Milan via Wikimedia Commons</a></small></p>
<p>The post <a href="https://www.rweber.net/javascript/tweaking-simple-auto-playing-slideshow/">Tweaking the simple auto-playing slideshow</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/javascript/tweaking-simple-auto-playing-slideshow/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">38469</post-id>	</item>
		<item>
		<title>Relative Position</title>
		<link>https://www.rweber.net/css/relative-position/</link>
					<comments>https://www.rweber.net/css/relative-position/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 27 Jul 2015 12:00:47 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[website layout]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=21694</guid>

					<description><![CDATA[<div><img width="300" height="169" src="https://www.rweber.net/wp-content/uploads/2015/07/Pantograph01-300x169.jpg" class="attachment-medium size-medium wp-post-image" alt="image of pantograph copying device" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/07/Pantograph01-300x169.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/07/Pantograph01-768x432.jpg 768w, https://www.rweber.net/wp-content/uploads/2015/07/Pantograph01.jpg 1024w, https://www.rweber.net/wp-content/uploads/2015/07/Pantograph01-150x84.jpg 150w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>Here, at great length, is the sequel to my post on aspect ratio, about vertical positioning. Again, horizontally, everything is easy &#8211; declare width: and left: as percentages, and as the screen size changes, they will change in tandem. For vertical positioning originally (i.e., almost a year ago &#8211; but then again, only almost a [&#8230;]</p>
<p>The post <a href="https://www.rweber.net/css/relative-position/">Relative Position</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="169" src="https://www.rweber.net/wp-content/uploads/2015/07/Pantograph01-300x169.jpg" class="attachment-medium size-medium wp-post-image" alt="image of pantograph copying device" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/07/Pantograph01-300x169.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/07/Pantograph01-768x432.jpg 768w, https://www.rweber.net/wp-content/uploads/2015/07/Pantograph01.jpg 1024w, https://www.rweber.net/wp-content/uploads/2015/07/Pantograph01-150x84.jpg 150w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>Here, at great length, is the sequel to <a href="https://www.rweber.net/web-development/css/aspect-ratio/">my post on aspect ratio</a>, about vertical positioning. Again, horizontally, everything is easy &#8211; declare width: and left: as percentages, and as the screen size changes, they will change in tandem.</p>
<p>For vertical positioning originally (i.e., almost a year ago &#8211; but then again, <em>only</em> almost a year ago) I thought it would be easiest to have a div above the one in question that always pushes it down by the correct amount, but you either have to do the aspect ratio business on it or slice your images so the aspect ratio is taken care of that way (hence my <a href="https://www.rweber.net/web-development/css/eliminating-white-space/">post on white space</a>). However, and I&#8217;m sure I read this when I was reading about padding but had it fly out of my brain for a while, not only is percent padding calculated from the width of the object, percent margin is too. Setting margin-top to the appropriate percentage will keep your objects in the correct vertical alignment upon resizing.</p>
<p>Just as with padding, though, in practice I didn&#8217;t get the predicted margin from my numbers.</p>
<p>If you know the percentage of the padded div&#8217;s width that your margin should be, and your padded div is not 100% of its container, you make the same calculation as for padding: (coded margin) = (desired margin)*(width). I have discovered that there is one situation where a div that is not 100% of its container is great: giving some element the same margin to the left and top edges of the screen. Suppose I want a margin that is 5% of the screen width, on an element that is 20% of the screen width. I can do <code>left: 5%;</code> and then calculate a margin-top. If the 20%-wide element is sitting immediately within a container that is the full width of the screen, the calculation simplifies nicely: 5% of the screen is 5% * 100% / 20% of the element (desired margin), but then you have to make the adjustment of multiplying by the width, 20%. You get (coded margin) = 5% * 100% / 20% * 20% = 5%, or (coded margin) = (desired margin).</p>
<p>One advantage to this method, aside from the lack of reassembled background slices, is that if you don&#8217;t have something from which to calculate a good margin or padding percentage it&#8217;s easy to tweak them and see how they look. I find myself occasionally mocking up pages without the final graphics in hand, so there&#8217;s a limit to how much arithmetic I want to do to fit everything together perfectly.</p>
<p>One final note: The reason this got put on the back burner originally is that I had unwittingly swapped out top and margin-top, so my test page was not working as expected. While left and margin-left are interchangeable for absolutely positioned elements, top and margin-top are not at all. Left, right, top, and bottom percentages refer to the height or width of the containing box according to whether they are height or width measurements; margin percentages are always according to the width of the containing box. Hence you will need margin for relative vertical positioning, though you may then need to set <code>top: 0;</code> to make sure your element is positioned relative to the top of the window.</p>
<p><small>3D pantograph rendering by Joseph Lertola, via <a href="https://en.wikipedia.org/wiki/Pantograph#/media/File:Pantograph01.jpg">Wikimedia Commons</a>.</small></p>
<p>The post <a href="https://www.rweber.net/css/relative-position/">Relative Position</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/css/relative-position/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">21694</post-id>	</item>
		<item>
		<title>Conquering scrollbars</title>
		<link>https://www.rweber.net/css/conquering-scrollbars/</link>
					<comments>https://www.rweber.net/css/conquering-scrollbars/#comments</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 06 Jul 2015 12:00:34 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Fancy Fifteen]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[website layout]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=38333</guid>

					<description><![CDATA[<div><img width="300" height="150" src="https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-300x150.png" class="attachment-medium size-medium wp-post-image" alt="image of tangled scroll" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-300x150.png 300w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-768x384.png 768w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-1024x512.png 1024w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-150x75.png 150w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280.png 1280w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>So suppose you want to fix the sidebar on a Twenty Fifteen WordPress site, because most of the time it's going to be short enough to fit entirely on the screen. And suppose you don't want the nice wide scrollbar Internet Explorer (even 11) will put down the edge of your sidebar whether or not scrolling is happening or even possible. Let's talk about that.</p>
<p>The post <a href="https://www.rweber.net/css/conquering-scrollbars/">Conquering scrollbars</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="150" src="https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-300x150.png" class="attachment-medium size-medium wp-post-image" alt="image of tangled scroll" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-300x150.png 300w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-768x384.png 768w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-1024x512.png 1024w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280-150x75.png 150w, https://www.rweber.net/wp-content/uploads/2015/07/ribbon-32696_1280.png 1280w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>So suppose you want to fix the sidebar on a Twenty Fifteen WordPress site, because most of the time it&#8217;s going to be short enough to fit entirely on the screen. Maybe it&#8217;s not always going to be, or maybe it&#8217;s just a little too long so you want to have it scrollable but not tied to the scrolling of the rest of the page. You can do that. Actually, it&#8217;s pretty easy if you aren&#8217;t concerned with aesthetics: <code>position:fixed; height:100%; overflow:scroll;</code> on the sidebar should cover you. However, Internet Explorer (even 11) will put a nice wide scrollbar down the edge of your sidebar whether or not scrolling is happening or even possible. Here we&#8217;ll talk about making that not happen.</p>
<p>The key is a lightweight jQuery plugin called <a href="http://rocha.la/jQuery-slimScroll/">jQuery-slimScroll</a>. It adds a lovely and styleable scrollbar only as necessary, and allows you to avoid overflow:scroll entirely (which is the source of the IE scrollbar).</p>
<p>In your wp-content/themes/fancyfifteen folder you&#8217;ll need 4 files: functions.php, style.css, aqa-pretty-scrolling.js, and header.php (the scrolling requires adding a wrapper to the sidebar content, which in Twenty Fifteen is in the header file).</p>
<p>As will now be standard, you can get the code for all of my Twenty Fifteen modifications in one big (but separable) <a href="https://github.com/ReveWeber/fancyfifteen">Twenty Fifteen child theme on GitHub</a>.</p>
<p>header.php:<br />
<iframe src="https://pastebin.com/embed_iframe.php?i=H5b9vFFV" style="border:none;width:100%"></iframe></p>
<p>The only thing in header.php that is different is the div with id &#8220;pretty-scroll&#8221;, just inside the div with id &#8220;sidebar&#8221;. Everything else is exactly as in Twenty Fifteen, which is why I haven&#8217;t bothered making this very large.</p>
<p>functions.php:<br />
<iframe src="https://pastebin.com/embed_iframe.php?i=hvTWxVHB" style="border:none;width:100%"></iframe></p>
<p>This is also very standard: enqueue your parent and child stylesheets, then enqueue jQuery-slimScroll and our JavaScript program that makes use of it. These enqueuings could be combined.</p>
<p>style.css:<br />
<iframe src="https://pastebin.com/embed_iframe.php?i=p81eN61a" style="border:none;width:100%;height:400px;"></iframe></p>
<p>This is simple but getting more interesting. The sidebar isn&#8217;t along the side until the screen gets sufficiently large, hence the media query. If a visitor has JavaScript turned off, they will get a fixed sidebar with overflow: scroll, trading an ugly scrollbar for a usable sidebar. Otherwise, the code will tack on the hide-scroll class, erasing the scrollbar. The rest of the styles bring the widgets closer together; if you are not accordion-folding them you may not want them closer, but then again if you&#8217;re not accordioning them what are the odds you have few enough to want to fix your sidebar?</p>
<p>aqa-pretty-scrolling.js:<br />
<iframe src="https://pastebin.com/embed_iframe.php?i=bFQnD8wR" style="border:none;width:100%;height:275px;"></iframe></p>
<p>Finally, we have the little bit of code that sets everything up and activates jQuery-slimScroll. If the sidebar is fixed (this seemed an easier indicator to use than sizes), the sidebar and pretty-scroll div get overflow:hidden on them, and then slimScroll scrolls pretty-scroll within sidebar. If you have trouble with bits of your sidebar not scrolling with the rest, uncomment the line that sets position: relative on pretty-scroll. For a quick and easy style match, set the scrollbar color to one of your site&#8217;s main colors. It will be translucent, so a darker one will likely look better.</p>
<p>There you have it. It took a little while for me to get this set up so there was no scrollbar visible on IE, but now that I have a template I&#8217;ll be using this whenever I have a piece of a page that scrolls independently of the rest of the page.</p>
<p><small>Complicated scroll from <a href="https://pixabay.com/en/ribbon-fancy-banner-scroll-border-32696/">Pixabay</a></small></p>
<p>The post <a href="https://www.rweber.net/css/conquering-scrollbars/">Conquering scrollbars</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/css/conquering-scrollbars/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">38333</post-id>	</item>
	</channel>
</rss>
