CSS Questions:Front-end Developer Interview Questions
Describe what a "reset" CSS file does and how it's useful.
- What Is A CSS Reset?
A CSS Reset (or “Reset CSS”) is a short, often compressed (minified) set of CSS rules that resets the styling of all HTML elements to a consistent baseline.
In a word,reset.css is used to normalize browser's default styles. - Why USE A CSS Reset?
Browser have different "built-in" styles which they apply to different html-elements. These styledefinitions may vary accross different browsers. Which CSS Reset Should I Use?
- Normalize.css is a customisable CSS file that makes browsers render all elements more consistently and in line with modern standards.
- If you’re working with HTML5, use the HTML5 Doctor Reset CSS
- If you’re doing some quick prototyping and testing, or building a non-HTML5 page, use Eric Meyer’s Reset CSS.
- If you want a CSS Reset that acts more as a framework, un-resetting styles after the CSS Reset, use the Tripoli CSS Reset or the Vanilla CSS Un-Reset
- If you want a full-featured CSS Framework, try using and abusing all the modules of the YUI 3 CSS Library
- Generally speaking, don’t use the Universal Selector ‘*’ CSS Reset
Describe Floats and how they work.
A float element in page like a boat in water.
What are the various clearing techniques and which is appropriate for what context?
- The Empty Div Method is, quite literally, an empty div. <div style="clear: both;"></div>. Sometimes you'll see a <br /> element or some other random element used, but div is the most common because it has no brower default styling, doesn't have any special function, and is unlikely to be generically styled with CSS. This method is scorned by semantic purists since its presence has no contexual meaning at all to the page and is there purely for presentation. Of course in the strictest sense they are right, but it gets the job done right and doesn't hurt anybody.
- The Overflow Method relies on setting the overflow CSS property on a parent element. If this property is set to auto or hidden on the parent element, the parent will expand to contain the floats, effectively clearing it for succeeding elements. This method can be beautifully semantic as it may not require an additional elements. However if you find yourself adding a new div just to apply this, it is equally as unsemantic as the empty div method and less adaptable. Also bear in mind that the overflow property isn't specifically for clearing floats. Be careful not to hide content or trigger unwanted scrollbars.
- The Easy Clearing Method uses a clever CSS pseudo selector (:after) to clear floats. Rather than setting the overflow on the parent, you apply an additional class like "clearfix" to it. Then apply this CSS:
.clearfix:after {
content: ".";
visibility: hidden;
display: block;
height: 0;
clear: both;
}
This will apply a small bit of content, hidden from view, after the parent element which clears the float. This isn't quite the [whole story](http://www.positioniseverything.net/easyclearing.html), as additional code needs to be used to accomodate for older browsers.
Explain CSS sprites, and how you would implement them on a page or site.
CSS sprites are a way to reduce the number of HTTP requests made for image resources referenced by your site. Images are combined into one larger image at defined X and Y coorindates. Having assigned this generated image to relevant page elements the background-position CSS property can then be used to shift the visible area to the required component image.(Css sprites is a technology to combin many image into one, and use css background-position to find which part you want)
CSS Sprites are the preferred method for reducing the number of image requests. Combine your background images into a single image and use the CSS background-image and background-position properties to display the desired image segment.
What are your favourite image replacement techniques and which do you use when?
CSS image replacement is a technique of replacing a text element (usually a header tag) with an image.
css-image-replacement
CSS property hacks, conditionally included .css files, or... something else?
How do you serve your pages for feature-constrained browsers?
What techniques/processes do you use?
- Progressive Enhancement
- Graceful Degradation
What are the different ways to visually hide content (and make it available only for screen readers)?
Have you ever used a grid system, and if so, what do you prefer?
Of course yes.
- gridpak. A simple grid system.
- Bootstrap Grid System
- Grid960
- YUI CSS Grid
I prefer Bootstrap grid.
Have you used or implemented media queries or mobile specific layouts/CSS?
Of course yes.
I implemented media queries on my gitbub pages.the site works fine on all media included handle devices.
Any familiarity with styling SVG?
How do you optimize your webpages for print?
- Create A Stylesheet For Print
- Avoid Unnecessary HTML Tables
- Hiding Needless Element For Print
- Size Page For Print
- Use Page Break
What are some of the "gotchas" for writing efficient CSS?
- Use efficient CSS selectors
- Avoid a universal key selector.
Allow elements to inherit from ancestors, or use a class to apply a style to multiple elements. - Make your rules as specific as possible.
Prefer class and ID selectors over tag selectors. - Remove redundant qualifiers.
These qualifiers are redundant:- ID selectors qualified by class and/or tag selectors
- Class selectors qualified by tag selectors (when a class is only used for one tag, which is a good design practice anyway).
- Avoid using descendant selectors, especially those that specify redundant ancestors.
For example, the rule body ul li a {...} specifies a redundant body selector, since all elements are descendants of the body tag. - Use class selectors instead of descendant selectors.
- Avoid a universal key selector.
- Avoid CSS expressions
- Put CSS in the document head
What are the advantages/disadvantages of using CSS preprocessors? (SASS, Compass, Stylus, LESS)
If so, describe what you like and dislike about the CSS preprocessors you have used.
How would you implement a web design comp that uses non-standard fonts?
Webfonts (font services like: Google Webfonts, Typekit etc.)
Explain how a browser determines what elements match a CSS selector?
As the browser parses HTML, it constructs an internal document tree representing all the elements to be displayed. It then matches elements to styles specified in various stylesheets, according to the standard CSS cascade, inheritance, and ordering rules. In Mozilla's implementation (and probably others as well), for each element, the CSS engine searches through style rules to find a match. The engine evaluates each rule from right to left, starting from the rightmost selector (called the "key") and moving through each selector until it finds a match or discards the rule. (The "selector" is the document element to which the rule should apply.)
Explain your understanding of the box model and how you would tell the browser in CSS to render your layout in different box models.
All HTML elements can be considered as boxes. In CSS, the term "box model" is used when talking about design and layout.
The CSS box model is essentially a box that wraps around HTML elements, and it consists of: margins, borders, padding, and the actual content.
Important: When you set the width and height properties of an element with CSS, you just set the width and height of the content area. To calculate the full size of an element, you must also add the padding, borders and margins.
IE8 and earlier versions of IE, included padding and border in the width property.
To fix this problem, add a <!DOCTYPE html> to the HTML page.
The box-sizing CSS property is used to alter the default CSS box model used to calculate widths and heights of elements. It is possible to use this property to emulate the behavior of browsers that do not correctly support the CSS box model specification.
CSS Questions:Front-end Developer Interview Questions的更多相关文章
- Front-end Developer Interview Questions
Front-end-Developer-Interview-Questions A list of helpful front-end related questions you can use to ...
- HTML Questions:Front-end Developer Interview Questions
What's a doctype do? Instruct the browser to render the page. What's the difference between standard ...
- General Questions:Front-end Developer Interview Questions
What did you learn yesterday/this week? Learning Angular. What excites or interests you about coding ...
- jQuery Questions:Front-end Developer Interview Questions
Explain "chaining". Chaining allows us to run multiple jQuery methods (on the same element ...
- JS Questions:Front-end Developer Interview Questions
Explain event delegation Event delegation allows us to attach a single event listener, to a parent e ...
- WCF学习系列二---【WCF Interview Questions – Part 2 翻译系列】
http://www.topwcftutorials.net/2012/09/wcf-faqs-part2.html WCF Interview Questions – Part 2 This WCF ...
- WCF学习系列三--【WCF Interview Questions – Part 3 翻译系列】
http://www.topwcftutorials.net/2012/10/wcf-faqs-part3.html WCF Interview Questions – Part 3 This WCF ...
- WCF学习系列四--【WCF Interview Questions – Part 4 翻译系列】
WCF Interview Questions – Part 4 This WCF service tutorial is part-4 in series of WCF Interview Qu ...
- 300+ Manual Testing and Selenium Interview Questions and Answers
Manual testing is a logical approach and automation testing complements it. So both are mandatory an ...
随机推荐
- loadrunner解决“服务器正在运行中”方法
问题现象: 这个问题在上家公司遇见过,今天无意中找到了解决办法: 解决方法: 打开任务管理器: 找到这个进程:ThumbProcess.exe,关掉这个进程即可解决. 今天运行lr的vugen报错 解 ...
- volatile的理解
用法解释 一旦一个共享变量(类的成员变量.类的静态成员变量)被volatile修饰之后,那么就具备了两层语义: 1)保证了不同线程对这个变量进行操作时的可见性,即一个线程修改了某个变量的值,这新值对其 ...
- 模拟 ACdream 1196 KIDx's Pagination
题目传送门 /* 简单模拟:考虑边界的情况输出的是不一样的,还有思维好,代码能短很多 */ #include <cstdio> #include <iostream> #inc ...
- BZOJ3560 : DZY Loves Math V
因为欧拉函数是非完全积性函数,所以可以考虑对每个数进行分解质因数,将每个质数的解乘起来即可. 对于一个质数$p$,设它在各个数中分别出现了$b_1,b_2,...b_n$次,那么由生成函数和欧拉函数的 ...
- BZOJ3571 : [Hnoi2014]画框
题目是要求最小乘积最小权匹配, 将一种方案看做一个二维点(x,y),x=a值的和,y=b值的和,所有方案中只有在下凸壳上的点才有可能成为最优解 首先要求出两端的方案l,r两个点 l就是a值的和最小的方 ...
- C#的泛型委托Predicate/Func/Action(转)
Predicate 泛型委托:表示定义一组条件并确定指定对象是否符合这些条件的方法.此委托由 Array 和 List 类的几种方法使用,用于在集合中搜索元素. 类型参数介绍: T: 要比较的对 ...
- Codeforces Round #204 (Div. 2) A.Jeff and Digits
因为数字只含有5或0,如果要被90整除的话必须含有0,否则输出-1 如果含有0的话,就只需考虑组合的数字之和是9的倍数,只需要看最大的5的个数能否被9整数 #include <iostream& ...
- TYVJ P1077 有理逼近 Label:坑,tle的好帮手 不懂
描述 对于一个素数P,我们可以用一系列有理分数(分子.分母都是不大于N的自然数)来逼近sqrt(p),例如P=2,N=5的时候:1/1<5/4<4/3<sqrt(2)<3/2& ...
- 【BZOJ】2321: [BeiJing2011集训]星器(数学+特殊的技巧)
http://www.lydsy.com/JudgeOnline/problem.php?id=2321 完全想不到.. 第一眼以为是爆搜,看到数据范围果断放弃:第二眼以为是网络流(因为只有行列操作, ...
- CSS中zoom:1的作用 ,小标签大作用
CSS中zoom:1的作用兼容IE6.IE7.IE8浏览器,经常会遇到一些问题,可以使用zoom:1来解决,有如下作用:触发IE浏览器的haslayout解决ie下的浮动,margin重叠等一些问题. ...