You can try this jsfiddle: https://jsfiddle.net/43f5qjc8/7/ . Since the image source is not very reliable, here is another jsfiddle with smaller images from another source: https://jsfiddle.net/43f5qjc8/13/ .
It includes some Javascript to calculate the minimum width needed to display content that can wrap in multiple lines. If there is a way to get the same result using CSS only, I did not find it.
Here is the Javascript code:
$(function () { $('.opendialog').click(function () { openDialog(); }); function openDialog() { var opt = { autoOpen: false, modal: true, width: 'auto', dialogClass: 'noTitle', focus: function () { var width = 0; $('#loginLogos > .logoRow').each(function () { var x = $(this).position().left; var w = $(this).outerWidth(); var tmpWidth = x + w; width = Math.max(width, tmpWidth); }); $('#loginLogos').width(width); var outerWidth = $('#loginBox').outerWidth(); $('#loginLogos').width('auto'); return $(this).dialog('option', 'width', outerWidth); } }; $("#loginBox").dialog(opt); return $("#loginBox").dialog("open"); } });
HTML markup:
<a href='#' class="opendialog">Open</a> <div id="loginBox" style="display:none"> <div>Login/Sign Up</div> <div id="loginLogos"> <div class="logoRow"> <a href="/auth/google"><img border="0" alt="Google" src="..."></a> <a href="/auth/facebook"><img border="0" alt="Facebook" src="..."></a> </div> <div class="logoRow"> <a href="/auth/twitter"><img border="0" alt="Twitter" src="..."></a> <a href="/auth/linkedin"><img border="0" alt="LinkedIn" src="..."></a> </div> </div> </div>
And CSS styles:
body { background-color: gray; } #loginBox { font-family: 'russo_oneregular'; font-size: 20px; display: inline-block; } #loginLogos { position: relative; } .logoRow { display: inline-block; }
ConnorsFan
source share