What’s the difference between align-content and align-items?

The align-items property of flex-box aligns the items inside a flex container along the cross axis just like justify-content does along the main axis. (For the default flex-direction: row the cross axis corresponds to vertical and the main axis corresponds to horizontal. With flex-direction: column those two are interchanged respectively). Here’s an example of how … Read more

How to make layout with rounded corners..?

1: Define layout_bg.xml in drawables: <?xml version=”1.0″ encoding=”UTF-8″?> <shape xmlns:android=”http://schemas.android.com/apk/res/android”> <solid android:color=”#FFFFFF”/> <stroke android:width=”3dp” android:color=”#B1BCBE” /> <corners android:radius=”10dp”/> <padding android:left=”0dp” android:top=”0dp” android:right=”0dp” android:bottom=”0dp” /> </shape> 2: Add layout_bg.xml as background to your layout android:background=”@drawable/layout_bg”

Using jQuery to center a DIV on the screen

I like adding functions to jQuery so this function would help: jQuery.fn.center = function () { this.css(“position”,”absolute”); this.css(“top”, Math.max(0, (($(window).height() – $(this).outerHeight()) / 2) + $(window).scrollTop()) + “px”); this.css(“left”, Math.max(0, (($(window).width() – $(this).outerWidth()) / 2) + $(window).scrollLeft()) + “px”); return this; } Now we can just write: $(element).center(); Demo: Fiddle (with added parameter)

How do you keep parents of floated elements from collapsing? [duplicate]

Solution 1: The most reliable and unobtrusive method appears to be this: Demo: http://jsfiddle.net/SO_AMK/wXaEH/ HTML: <div class=”clearfix”> <div style=”float: left;”>Div 1</div> <div style=”float: left;”>Div 2</div> </div>​ CSS: .clearfix::after { content: ” “; display: block; height: 0; clear: both; } ​With a little CSS targeting, you don’t even need to add a class to the parent … Read more

What is a clearfix?

If you don’t need to support IE9 or lower, you can use flexbox freely, and don’t need to use floated layouts. It’s worth noting that today, the use of floated elements for layout is getting more and more discouraged with the use of better alternatives. display: inline-block – Better Flexbox – Best (but limited browser … Read more

How to get screen dimensions as pixels in Android

If you want the display dimensions in pixels you can use getSize: Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); int width = size.x; int height = size.y; If you’re not in an Activity you can get the default Display via WINDOW_SERVICE: WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); If you … Read more

Get the size of the screen, current web page and browser window

You can get the size of the window or document with jQuery: // Size of browser viewport. $(window).height(); $(window).width(); // Size of HTML document (same as pageHeight/pageWidth in screenshot). $(document).height(); $(document).width(); For screen size you can use the screen object: window.screen.height; window.screen.width;

tech