Foundation – Media Queries

Foundation – Media Queries ”; Previous Next Media queries are CSS3 module that include media features such as width, height, color and displays the content as per the specified screen resolution. Foundation uses the following media queries to create breakdown ranges − Small − Used for any screen. Medium − It is used for screens of 640 pixels and wider. Large − It is used for screens of 1024 pixels and wider. You can change the screen size by using the breakpoint classes. For instance, you can use .small-6 class for small sized screens and .medium-4 class for medium sized screens as shown in the following code snippet − <div class = “row”> <div class = “small-6 medium-4 columns”></div> <div class = “small-6 medium-8 columns”></div> </div> Changing the Breakpoints You can change the breakpoints, if your application uses SASS version of Foundation. You can place the breakpoints name under the $breakpoints variable in the settings file as shown below − $breakpoints: ( small: 0px, medium: 640px, large: 1024px, xlarge: 1200px, xxlarge: 1440px, ); You can change the breakpoints classes in the settings file by modifying the $breakpoint-classes variable. If you want to use .large class in the CSS, then add it to the end of the list as shown below − $breakpoints-classes: (small medium large); Suppose, you want to use .xlarge class in the CSS, and then add this class to the end of the list as shown below − $breakpoints-classes: (small medium large xlarge); SASS The Breakpoint Mixin You can write the media queries by using breakpoint() mixin along with @include. Use the down or only keywords along with the breakpoint value to change the behavior of the media query as shown in the following code format − .class_name { // code for medium screens and smaller @include breakpoint(medium down) { } // code for medium screens only @include breakpoint(medium only) { } } You can use three media queries portrait, landscape and retina for device orientation or pixel density and they are not width based media queries. Breakpoint Function You can use the functionality of breakpoint() mixin by using the internal function. The breakpoint() functionality can be used directly to write own media queries − @media screen and #{breakpoint(medium)} { // code for medium screens and up styles } JavaScript Working with Media Queries The Foundation JavaScript provides the MediaQuery.current function to access current breakpoint name on the Foundation.MediaQuery object as specified below − Foundation.MediaQuery.current The MediaQuery.current function displays small, medium, large as current breakpoint names. You can get the media query of breakpoint using the MediaQuery.get function as shown below − Foundation.MediaQuery.get(”small”) Sass Reference Variables The following table lists the SASS variables, which can be used to customize the default styles of the component − Sr.No. Name & Description Type Default Value 1 $breakpoints It is a breakpoint name which can be used to write the media queries by using breakpoint() mixin. Map small: 0px medium: 640px large: 1024px xlarge: 1200px xxlarge: 1440px 2 $breakpoint-classes You can change the CSS class output by modifying the $breakpoint-classes variable. List small medium large Mixins Mixins creates a group of styles to build your CSS class structure for the Foundation components. BREAKPOINT It uses breakpoint() mixin to create media queries and includes the following activities − If string is passed, then mixin searches the string in the $breakpoints map and creates the media query. If you are using pixel value, then convert it to em value using $rem-base. If rem value is passed, then it changes its unit to em. If you are using em value, then it can be used as it is. The following table specifies the parameter used by the breakpoint − Sr.No. Name & Description Type Default Value 1 $value It is processes the values by using breakpoint name, px, rem or em values. keyword or number None Functions BREAKPOINT It uses breakpoint() mixin to create media queries with matching input value. The following table specifies the possible input value used by the breakpoint − Sr.No. Name & Description Type Default Value 1 $val It processes the values by using breakpoint name, px, rem or em values. keyword or number small JavaScript Reference Functions There are two types of functions − .atLeast − It checks the screen. It must be wide at least as a breakpoint. .get − It is used to get the media query of the breakpoint. The following table specifies the parameter used by above functions − Sr.No. Name & Description Type 1 size It checks and gets the name of the breakpoint for the specified functions respectively. String Print Page Previous Next Advertisements ”;

Foundation – Forms

Foundation – Forms ”; Previous Next In this chapter, we will study about Forms. Foundation provides powerful, easy and versatile layout system for Forms, which combines form styles and grid support. The following table lists the form elements used in Foundation. Sr.No. Form element & Description 1 Form Basics Creation of forms is easy and very flexible, which are built with a combination of standardized form elements and powerful grid system. 2 Help Text It is used to notify the user about the purpose of the element and is usually placed below a field. 3 Label Positioning You can position your labels left or right of your inputs. 4 Inline Labels and Buttons Extra text or controls can be attached to the left/right of an input field. 5 Custom Controls Custom controls like date pickers, switches or sliders require some attention to access it. 6 SASS Reference You can change the styles of the components by using SASS Reference. Print Page Previous Next Advertisements ”;

Foundation – JavaScript Utilities

Foundation – JavaScript Utilities ”; Previous Next Foundation includes JavaScript utilities that are used to add common functionalities. It is very helpful and easy to use. This JavaScript utilities library can be found in the folder Your_folder_name/node_modules/foundation-sites/js Box Foundation.Box library consists of a couple of methods. The js/foundation.util.box.js is the script filename, which can be included while writing the code. Either jQuery objects or plain JavaScript elements can be pass to both methods. var dims = Foundation.Box.GetDimensions(element); The returned object specifies the dimension of the element as − { height: 54, width: 521, offset: { left: 198, top: 1047 }, parentDims: { height: … //The same format is share for parentDims and windowDims as the element dimensions. }, windowDims: { height: … } } Function ImNotTouchingYou is included. Based on the passed element, a Boolean value is returned, which is either a conflict with edge of the window or optional or a parent element. The two options specified in the line given below i.e. leftAndRightOnly, topAndBottomOnly is used to identify the collision on only one axis. var clear = Foundation.Box.ImNotTouchingYou ( element [, parent, leftAndRightOnly, topAndBottomOnly]); Keyboard There are many methods in Foundation.Keyboard, which helps to make the keyboard event interaction easy. The js/foundation.util.keyboard.js is the script filename, which can be included while writing the code. The object Foundation.Keyboard.keys consist key/value pairs, which keys are used in the framework more frequently. Whenever the key is pressed then Foundation.Keyboard.parseKey is called to get a string. This helps to manage your own keyboard inputs. The following code is used to find all focusable elements within the given $element. Therefore, there is no need of writing any function and selector by you. var focusable = Foundation.Keyboard.findFocusable($(”#content”)); The handleKey function is a main function of this library. This method is used to handle the keyboard event; it can be called whenever any plugin is registered with the utility. Foundation.Keyboard.register(”pluginName”, { ”TAB”: ”next” }); …//in event callback Foundation.Keyboard.handleKey(event, ”pluginName”, { next: function(){ //do stuff } }); The Foundation.Keyboard.register function can be called when you want to use your own key bindings. MediaQuery MediaQuery library is a backbone of all responsive CSS technique. The js/foundation.util.mediaQuery.js is the script filename, which can be included while writing the code. The Foundation.MediaQuery.atLeast(”large”) is used to check if the screen is at least as wide as a breakpoint. The Foundation.MediaQuery.get(”medium”) gets the media query of a breakpoint. The Foundation.MediaQuery.queries are an array of media queries, Foundation uses for breakpoints. The Foundation.MediaQuery.current is a string of the current breakpoint size. Foundation.MediaQuery.get(”medium”); Foundation.MediaQuery.atLeast(”large”); Foundation.MediaQuery.queries; Foundation.MediaQuery.current; The following code broadcasts the media query change on the window. $(window).on(”changed.zf.mediaquery”, function(event, newSize, oldSize){}); Motion & Move Foundation.Motion javascript is similar to Motion UI library, which is included in the Foundation 6. It is used to create custom CSS transitions and animations. The js/foundation.util.motion.js is the script filename, which can be included while writing the code. Foundation.Move is used to make CSS3 backed animation simple and elegant. requestAnimationFrame(); method tells the browser to perform an animation; it requests that your animation function be called before the browser performs the next repaint. Foundation.Move(durationInMS, $element, function() { //animation logic }); When the animation is completed, finished.zf.animate is fired. Timer & Images Loaded Orbit uses both, the function timer and the image loaded. The js/foundation.util.timerAndImageLoader.js is the script filename, which can be included while writing the code. var timer = new Foundation.Timer($element, {duration: ms, infinite: bool}, callback); The image-loaded method runs a callback function in your jQuery collection when images are completely loaded. Foundation.onImagesLoaded($images, callback); Touch The methods are used for adding pseudo drag events and swipe to elements. The js/foundation.util.touch.js is the script filename, which can be included while writing the code. The addTouch method is used to bind elements to touch events in the Slider plugin for mobile devices. The spotSwipe method binds the elements to swipe events in the Orbit plugin for mobile devices. $(”selector”).addTouch().on(”mousemove”, handleDrag); $(”selector”).spotSwipe().on(”swipeleft”, handleLeftSwipe); Triggers It triggers the specified event for the selected elements. The js/foundation.util.triggers.js is the script filename, which can be included while writing the code. The triggers are utilized in many Foundation plugin. $(”selector”).on(”open.zf.trigger”, handleOpen); $(”selector”).on(”close.zf.trigger”, handleClose); $(”selector”).on(”toggle.zf.trigger”, handleToggle); The following two methods are used in this library i.e. resize and scroll. The resize() method triggers the resize event when a resize event occurs. The scroll() method triggers the scroll event when a scroll event occurs. $(”#someId”).on(”scrollme.zf.trigger”, handleScroll); $(”#someId”).on(”resizeme.zf.trigger”, handleResize); Miscellaneous Foundation contains few features in the core library, which are used in many places. The js/foundation.core.js is the script filename, which can be included while writing the code. Foundation.GetYoDigits([number, namespace]) returns a random base-36 uid with namespacing. It returns the string length of 6 characters long by default. Foundation.getFnName(fn) returns a JavaScript function name. Foundation.transitionend occurs when CSS transition is completed. Print Page Previous Next Advertisements ”;