03.11.2016 Views

Beginning ASP.NET 4.5 in CSharp and VB Opsylum

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Work<strong>in</strong>g with CSS <strong>in</strong> Visual Studio x 87<br />

on the img element are ignored. For example the image <strong>in</strong> this code snippet ends up as a 100-pixel<br />

square:<br />

img<br />

{<br />

height: 100px;<br />

width: 100px;<br />

}<br />

...<br />

<br />

NOTE There’s a lot more to CSS than what is shown here. To learn more<br />

about CSS, pick up a copy of <strong>Beg<strong>in</strong>n<strong>in</strong>g</strong> CSS: Cascad<strong>in</strong>g Style Sheets for<br />

Web Design, 3rd Edition Wrox, 2011 by Richard York <strong>and</strong> Ian Pouncey (ISBN:<br />

978-0-470-89152-0).<br />

In general, it’s recommended that you attach external files at the top of the section, followed<br />

by embedded style sheets. That way, the external file def<strong>in</strong>es the global look of elements, <strong>and</strong> you<br />

can use embedded styles to overrule the external sett<strong>in</strong>gs on a page-by-page basis.<br />

VS makes it easy to move embedded style sheets to an external CSS file, someth<strong>in</strong>g you learn how to<br />

do <strong>in</strong> the next section, which discusses the rema<strong>in</strong>der of the CSS tools <strong>in</strong> VS.<br />

WORKING WITH CSS IN VISUAL STUDIO<br />

The previous version of VS already had a number of great tools on board to make work<strong>in</strong>g with CSS<br />

as easy as possible, <strong>in</strong>clud<strong>in</strong>g:<br />

‰ The CSS Properties Grid, which enables you to change property values.<br />

‰ The Manage Styles w<strong>in</strong>dow, which enables you to organize styles <strong>in</strong> your site, chang<strong>in</strong>g them<br />

from embedded to external style sheets <strong>and</strong> vice versa; reorder them; l<strong>in</strong>k exist<strong>in</strong>g style sheets<br />

to a document; <strong>and</strong> create new <strong>in</strong>l<strong>in</strong>e, embedded, or external style sheets.<br />

‰ The Apply Styles w<strong>in</strong>dow, which you can use to choose from all available styles <strong>in</strong> your site<br />

<strong>and</strong> quickly apply them to elements <strong>in</strong> your page.<br />

‰ The Style Builder, which you can use to visually create declarations, as you saw earlier.<br />

In VS 2012, the CSS tools have been greatly enhanced <strong>and</strong> now support the follow<strong>in</strong>g options<br />

as well:<br />

‰ Hierarchical <strong>in</strong>dent<strong>in</strong>g, which makes your CSS code easier to underst<strong>and</strong>.<br />

‰ Smarter IntelliSense features, which makes it easy to enter CSS code manually.<br />

‰ A number of helpful editor features such as the ability to easily comment <strong>and</strong> uncomment<br />

code, wrap code <strong>in</strong> collapsible regions, a color picker, <strong>and</strong> code snippets.<br />

The next sections give you a detailed look at these tools.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!