<?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>cross-site interaction Archives - rweber.net</title>
	<atom:link href="https://www.rweber.net/tag/cross-site-interaction/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.rweber.net/tag/cross-site-interaction/</link>
	<description>trying to be a mile wide AND a mile deep</description>
	<lastBuildDate>Wed, 19 Sep 2018 11:30:24 +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>Coding a Social Share Widget</title>
		<link>https://www.rweber.net/javascript/coding-a-social-share-widget/</link>
					<comments>https://www.rweber.net/javascript/coding-a-social-share-widget/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 17 Sep 2018 12:00:11 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[cross-site interaction]]></category>
		<guid isPermaLink="false">https://www.rweber.net/?p=40550</guid>

					<description><![CDATA[<div><img width="290" height="300" src="https://www.rweber.net/wp-content/uploads/2018/09/root-beer-float-290x300.jpg" class="attachment-medium size-medium wp-post-image" alt="Root Beer Float image by Darin House via Wikimedia Commons" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" fetchpriority="high" srcset="https://www.rweber.net/wp-content/uploads/2018/09/root-beer-float-290x300.jpg 290w, https://www.rweber.net/wp-content/uploads/2018/09/root-beer-float-768x794.jpg 768w, https://www.rweber.net/wp-content/uploads/2018/09/root-beer-float.jpg 991w, https://www.rweber.net/wp-content/uploads/2018/09/root-beer-float-145x150.jpg 145w" sizes="(max-width: 290px) 100vw, 290px" /></div>
<p>Syntax and tips for cooking up your own widget for sharing by email, Twitter, Facebook, or Pinterest.</p>
<p>The post <a href="https://www.rweber.net/javascript/coding-a-social-share-widget/">Coding a Social Share Widget</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="290" height="300" src="https://www.rweber.net/wp-content/uploads/2018/09/root-beer-float-290x300.jpg" class="attachment-medium size-medium wp-post-image" alt="Root Beer Float image by Darin House via Wikimedia Commons" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" srcset="https://www.rweber.net/wp-content/uploads/2018/09/root-beer-float-290x300.jpg 290w, https://www.rweber.net/wp-content/uploads/2018/09/root-beer-float-768x794.jpg 768w, https://www.rweber.net/wp-content/uploads/2018/09/root-beer-float.jpg 991w, https://www.rweber.net/wp-content/uploads/2018/09/root-beer-float-145x150.jpg 145w" sizes="(max-width: 290px) 100vw, 290px" /></div><p>Suppose you want a homegrown share widget: perhaps for page load speed, perhaps for styling control, perhaps to avoid adding a vendor&#8217;s tracking code to your site. As it turns out, this is straightforward to do for a lot of social networks with a little JavaScript: add an <code>onclick</code> attribute opening a window at the appropriate URL, and you&#8217;re done.</p>
<p>Email is even simpler &#8211; no JavaScript required. <code>Mailto:</code> links have been around since the early days of the web. (Not that everyone&#8217;s browser is configured correctly to use their preferred mail client.) For a share button the destination is omitted but the subject and body are set via parameters.</p>
<p><code>href="mailto:?subject=[encoded string]&body=[encoded string]"</code></p>
<p>I found just one complication: if you encode the ampersand between subject and body in the mailto link, as most places instruct, the body will be cut off in many circumstances. One of the problematic setups is Outlook on Windows, yet even MSDN says to encode the ampersand!</p>
<p>Twitter, Facebook, and Pinterest sharing buttons follow. For each of them, you will be opening a window at a specific address. The links get the following attribute:<br />
<code>onclick="window.open('[network-specific link]', 'window', 'menubar=no, toolbar=no, resizable=yes, scrollbars=yes, height=600, width=600')"</code></p>
<p>Twitter is the second-simplest to set up. Its network-specific link is<br />
<code>https://twitter.com/intent/tweet?text=[encoded string]</code></p>
<p>Facebook&#8217;s complication is that you need an app ID. This ID will be exposed, so do not use an app that Facebook users sign up for. A special app that is used for nothing but this widget is best. Incidentally, if someone clicks the Facebook share button when they are not logged in, they will see the name of the app (a la &#8220;Sign in to Facebook to use XYZ&#8221;), so you may want to give it a name that will make sense to the user.</p>
<p>Facebook makes its own decisions about what to show for a shared page, so you only provide it the URL:<br />
<code>https://www.facebook.com/dialog/share?app_id=[app ID]&href=[encoded page URL]</code></p>
<p>The minimalist network-specific link for Pinterest is almost as simple as Twitter&#8217;s:<br />
<code>https://www.pinterest.com/pin/create/button/?url=[encoded page URL]&description=[encoded text]</code></p>
<p>That will open a window that allows you to choose an image from the page to pin, as though you&#8217;d pinned by URL from within Pinterest itself. It&#8217;s great &hellip; provided you&#8217;re not trying to manage which images are pinnable.</p>
<p>Once upon a time, to exclude an individual image from being pinned, you gave it the attribute <code>nopin="nopin"</code>. That&#8217;s not valid HTML5, though, so now there is also the attribute <code>data-pin-nopin="true"</code>. If you are using, say, the Pinterest browser extension, adding the data-attribute to exclude images works great and allows your page to validate. However, in the context of choosing an image to pin after inputting a URL to Pinterest, <code>nopin="nopin"</code> is still current. Imagine my joy upon discovering my sitewide update from nopin to data-pin-nopin attributes was not as much of an update as I thought!</p>
<p>Fortunately, it isn&#8217;t too complicated to build an image selection overlay which excludes disallowed images regardless of syntax. Mine also kicks out any images that are too small (using size as displayed) or too landscape-oriented, but pulls in anything that appears to have special Pinterest markup &#8211; whether that be from a <code>data-pin-media</code> attribute or based on a CSS class name. And then why not take it a step further &#8211; if there is only a single pinnable image, go straight to a Pinterest window to pin that image.</p>
<p>Here&#8217;s a pseudocode skeleton for a pinnable image gate:</p>
<pre>showPinnableImages:
  A. grab all images with neither data-pin-nopin="true" nor nopin="nopin" attribute; set a counter to 0.
  B. for each image, check
    1. does it have a data-pin-media attribute or a class including "pinterest"?
      > if so, push the data-pin-media value (falling back to src and then to srcset) into a media array, and the alt text (falling back to title + metadescription) into a description array; increment the counter.
    2. if not, is it at least 236px wide with a height at least 2/3 of its width?
      > if so, push the src (falling back to srcset) into the media array, and the alt text (falling back to title + metadescription) into the description array; increment the counter.
  C. if there is more than one image, build HTML of an overlay displaying the images with their description value as alt text.
  D. if there is only one image, open a Pinterest window to pin that image.
  E. set a click handler for the overlay and its contents, to close or pin as desired.</pre>
<p>Once you&#8217;ve chosen an image, the network-specific link for Pinterest for the window.open command looks like this:<br />
<code>https://www.pinterest.com/pin/create/button/?url=[encoded page URL]&description=[encoded text]&media=[encoded image URL]</code></p>
<p>The one major limitation to the home-grown share button is that if the Pinterest gate finds zero pinnable images, it will simply do nothing. There does exist open source code to generate a &#8220;text on solid color&#8221; image, but if that is overkill you can add another &#8220;if&#8221; to the block about number of pinnable images and pop up a pin window with a default image.</p>
<p>Other than the six-week period where Facebook was rate-limiting apps severely (and contrary to its documentation), these have worked quite well, eliminating problems with slow and obvious loading. I was really pleased with them!</p>
<hr>
<p><small>Root beer float original by <a href="https://commons.wikimedia.org/wiki/File:DPS_Assignment_-_Sweet_Tooth_-_Root_Beer_Float.jpg">Darin House via Wikimedia Commons</a>.</small></p>
<p>The post <a href="https://www.rweber.net/javascript/coding-a-social-share-widget/">Coding a Social Share Widget</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/javascript/coding-a-social-share-widget/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">40550</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>Social media connections</title>
		<link>https://www.rweber.net/developer-toolbox/social-media-connections/</link>
					<comments>https://www.rweber.net/developer-toolbox/social-media-connections/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 11 Jan 2016 13:00:57 +0000</pubDate>
				<category><![CDATA[Developer Toolbox]]></category>
		<category><![CDATA[cross-site interaction]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39266</guid>

					<description><![CDATA[<div><img width="300" height="246" src="https://www.rweber.net/wp-content/uploads/2015/12/Bell_System_switchboard-300x246.jpg" class="attachment-medium size-medium wp-post-image" alt="Bell Systems switchboard" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/12/Bell_System_switchboard-300x246.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/12/Bell_System_switchboard-768x630.jpg 768w, https://www.rweber.net/wp-content/uploads/2015/12/Bell_System_switchboard-150x123.jpg 150w, https://www.rweber.net/wp-content/uploads/2015/12/Bell_System_switchboard.jpg 1000w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div>
<p>Options for embedding content from social media in your website.</p>
<p>The post <a href="https://www.rweber.net/developer-toolbox/social-media-connections/">Social media connections</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="246" src="https://www.rweber.net/wp-content/uploads/2015/12/Bell_System_switchboard-300x246.jpg" class="attachment-medium size-medium wp-post-image" alt="Bell Systems switchboard" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2015/12/Bell_System_switchboard-300x246.jpg 300w, https://www.rweber.net/wp-content/uploads/2015/12/Bell_System_switchboard-768x630.jpg 768w, https://www.rweber.net/wp-content/uploads/2015/12/Bell_System_switchboard-150x123.jpg 150w, https://www.rweber.net/wp-content/uploads/2015/12/Bell_System_switchboard.jpg 1000w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>As various clients want various interactions with their social media accounts, I&#8217;ve gathered notes on what&#8217;s available and how to do it. This is mostly about drawing or embedding content from social media to standalone sites.</p>
<p>For single items, the built-in WordPress functionality <a href="https://codex.wordpress.org/Embeds#Okay.2C_So_What_Sites_Can_I_Embed_From.3F">oEmbed covers a lot</a>. You simply paste in the URL of the content you want to embed, and oEmbed pulls the appropriate HTML from the source site. This will frequently result in an iframe, of course, so you may wish to visit my post on <a href="https://www.rweber.net/web-development/css/responsive-iframes/">making iframes responsive</a>.</p>
<p>I have some notes on feeds and specific social media sites, too. Twitter makes it incredibly easy to get whatever kind of feed you want, provided you have an account. Users, hashtags, search terms, any criteria you could reasonably desire. While logged in, simply visit <a href="https://twitter.com/settings/widgets/new">the timeline widget creation page</a>, fill out the form, and grab the code from underneath the preview. It can go in a post or page &#8211; in the Text editor view only, not the Visual editor view &#8211; or in a WordPress text widget.</p>
<p>For YouTube, note that the embed URL begins with //. This is great for avoiding HTTP vs HTTPS conflicts, but I&#8217;ve had trouble with localhost sites figuring out what to do with it and have had to add http: to get the embed to happen. You can embed playlists queued up to any specific video in the list, but unfortunately not to the latest addition dynamically. Ads will still be in place and benefit Youtube and the video owner on Youtube, not the owner of the site where the video is embedded (unless, of course, that individual also owns the video).</p>
<p>While personal Facebook badges have many options, including exporting a photo stream (public photos only), page badges are limited to name, most recent status, current profile picture, and number of fans. Here is <a href="https://www.facebook.com/badges/">the badge page</a>.</p>
<p>If you want to get in deep with Pinterest, there are <a href="https://css-tricks.com/using-pinterest-data-attributes-and-meta-tags/">all kinds of Pinterest-specific data attributes</a> you can add to your images. That article also covers Rich Pins. I haven&#8217;t had any clients for whom Pinterest is important enough to put that kind of time into, and there don&#8217;t seem to be any plugins to facilitate adding the attributes, but they&#8217;re there for you if you do use Pinterest heavily for marketing.</p>
<p>Conversely, you can prevent pinning of your images with a meta tag (in the &lt;head&gt;&lt;/head&gt; section): <code>&lt;meta name="pinterest" content="nopin" description="Optional message text"&gt;</code> If you don&#8217;t set the description attribute the message displayed upon attempted pinning will be &#8220;This site doesn&#8217;t allow pinning to Pinterest. Please contact the owner with any questions. Thanks for visiting!&#8221; Individual images can be disqualified from pinning by adding the attribute <code>nopin="nopin"</code> to the img tag.</p>
<p><small>Bell Systems switchboard photo found on <a href="https://commons.wikimedia.org/wiki/File:Bell_System_switchboard.jpg">Wikimedia Commons</a>.</small></p>
<p>The post <a href="https://www.rweber.net/developer-toolbox/social-media-connections/">Social media connections</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/developer-toolbox/social-media-connections/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39266</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>
	</channel>
</rss>
