background preloader

Vertical align anything with just 3 lines of CSS

Vertical align anything with just 3 lines of CSS
With just 3 lines of CSS (excluding vendor prefixes) we can with the help of transform: translateY vertically center whatever we want, even if we don’t know its height. The CSS property transform is usally used for rotating and scaling elements, but with its translateY function we can now vertically align elements. Usually this must be done with absolute positioning or setting line-heights, but these require you to either know the height of the element or only works on single-line text etc. So, to vertically align anything we write: That’s all you need. It is a similar technique to the absolute-position method, but with the upside that we don’t have to set any height on the element or position-property on the parent. To make it even more simple, we can write it as a mixin: You can find a demo of it here: See the Pen Vertical center with only 3 lines of CSS by sebastianekstrom (@sebastianekstrom) on CodePen. Update (April 25th, 2014)

CSS: centering things See also the index of all tips. Centering lines of text The most common and (therefore) easiest type of centering is that of lines of text in a paragraph or in a heading. renders each line in a P or in a H2 centered between its margins, like this: The lines in this paragraph are all centered between the paragraph's margins, thanks to the value 'center' of the CSS property 'text-align'. Centering a block or image Sometimes it is not the text that needs to be centered, but the block as a whole. This rather narrow block of text is centered. This is also the way to center an image: make it into block of its own and apply the margin properties to it. The following image is centered: Centering vertically CSS level 2 doesn't have a property for centering things vertically. The example below centers a paragraph inside a block that has a certain given height. This small paragraph is vertically centered. Centering vertically in CSS level 3 CSS level 3 offers other possibilities. The essential rules are:

Master Pages In ASP.NET 2.0 A professional web site will have a standardized look across all pages. For example, one popular layout type places a navigation menu on the left side of the page, a copyright on the bottom, and content in the middle. It can be difficult to maintain a standard look if you must always put the common pieces in place with every web form you build. In ASP.NET 2.0, master pages will make the job easier. You’ll only need to write the common pieces once - in the master page. Marking Up Master Pages To add a master page to a web project, right-click your web project in the Solution Explorer window, select Add New Item, and select the Master Page item type from the Add New Item dialog. <! " <title>Untitled Page</title> <asp:MenuItem NavigateUrl="~/Experiments.aspx" Text="Experiments" Value="Experiments"/> Just like any ASPX form, our master page can contain code in a <script> block, or in a code-behind file, and can respond to page lifecycle events. EndIf

Getting StartED with CSS excerpts: Styling tables, backgrounds, and borders Knowledge of cascading style sheets (CSS) is essential for developing modern, attractive websites, but many beginners are put off by the need to learn about unfamiliar concepts, such as selectors, properties, and classes, before they can achieve anything. Getting StartED with CSS takes a practical approach by showing you how to use CSS in simple stages, starting by changing the default appearance of HTML tags to improve the look of text and links. It assumes no prior knowledge of CSS and avoids bombarding you with unnecessary technical details. At the same time, it explains all the main points and acts as a reference that you can come back to when you need to refresh your memory. Aimed at anybody who wants to learn how to style websites using CSS, this book covers the following topics: What Is CSS, and Why Should I Learn It? The printed book is available through Friends of Ed, an APress company. Getting StartED with CSS © 2009 David Powers. What Is CSS, and Why Should I Learn It?

Create CSS Sprites 1. Create your master image Divide a rectangle into four items, or as many icons as you need. Observe in this master image that our intended “before” link images are on the top row, with “after” :hover states immediately below. The total master image size is 205 x 103 pixels. This is important information to keep track of. Note that in this example we’ve added 1px borders around each image as well. 2. Light-weight, simple markup that degrades well in older and CSS-disabled browsers is what we are shooting for. Create an unordered list <ul> with a list item <li>for each icon. <ul id="iconmenu"><li id="panel1c"><a href="#">></a></li><li id="panel2c"><a href="#"></a></li><li id="panel3c"><a href="#"></a></li><li id="panel4c"><a href="#"></a></li></ul> We will not include any links at this point since this is just a demo. 3. We'll start with taking care of the unordered list id of #iconmenu Let's look at what the CSS is doing: 4. At this stage we have created the space for one icon. 5. 6. 7. 8.

How to Use Web Fonts and the @font-face CSS Method The days of web safe fonts are about to end thanks to all the great attempts of designers, developers and industry leaders around the world. The good thing in digital production industry is the community of people who are always pushing the boundaries to their limits. Then when it becomes a new standard or convention its pushed forward again by the same community even further. Technologies like Cufon, sIFR, FLIR and @font-face are some good examples of this. We will investigate the use of @font-face CSS method, which is stronger, simpler and more flexible. I still think with good use of typography this small list of web safe fonts are enough to create basic typographic impact, but having more options and variations also excite me in another way. What is @font-face @font-face is a CSS rule which allows you to embed a particular custom font from your server to render a webpage even if its not already installed on site visitor’s computer. Formats How web fonts are licensed? How to make it work

Place text over images on hover without JavaScript | Geek Girl Life Thanks to CSS3 and better and better browser support for it, we can accomplish things now with CSS that previously required fancy JavaScript work. In this tutorial, I’ll walk you through fading in text over an image on hover. Tutorial Updated I updated this tutorial to show you how to take advantage of even more CSS3 properties. The update is available here. Here’s a sample of what we’ll be creating: If you move your mouse over those images, you’ll see some text fade in that tells you where each photo was taken. Nice, right? Step 1: HTML Markup To keep things neat and tidy, I’m going to put my images in a list. I’d just repeat that list item and everything inside of it for each image that I wanted to include. Step 2: Style the Images Now that we’ve got the markup out of the way, let’s jump into the CSS. I’m setting the width and height of each list item to the width and height of my individual images, and then lining up the list items by setting them to display: inline-block.

How to Apply Table Formatting with CSS in Adobe Dreamweaver CS6 In addition to using the Property inspector in Adobe Dreamweaver CS6, you can format entire tables or individual table cells (and contents) by using CSS (cascading style sheets). In most cases, this is considered a better practice, as it maintains a separation between markup, content, and the actual styling used to make it aesthetically pleasing. You can use CSS to format a table as follows: Create a CSS Class rule from either the Property inspector or the CSS Styles panel. Similar to the way you can use the Property inspector to color and align individual cells, you can create and apply CSS rules to table cells. Create a CSS Class rule from either the Property inspector or the CSS Styles panel.

Top 10 CSS Table Designs CSS Styling Tables

Related: