HTML/CSS Service

Use shorthand CSS notation

Category: CSS Tips    |    756 views    |    Add a Comment  |   

CSS Customized Underlines

Category: CSS, CSS Tips    |    355 views    |    Add a Comment  |   

 

CSS Customized Underlines apply a border to the bottom of the link, which gives you control over the color of the underline (whereas text-decoration will only apply an underline in the same color as the text of the link itself) and also the pattern of the border:

a {
	text-decoration: none;
	border-bottom: 2px dotted #0c0;
}

Another way to apply more interesting underlines to links is to use small background images aligned to the bottom of the link that repeat horizontally: Read more…

Share/Save/Bookmark

  • No Related Post

 

css Images opacity

Category: CSS Tips    |    421 views    |    Add a Comment  |   

You Can Make Images Transparent Too

Set the opacity on the image itself and it will fade into the background. This is really useful for background images.

<img src=”http:///csshook.com/images/one.png” alt=”Shasta” style=”opacity:0.5;filter: alpha(opacity=50) ;” />

And if you add in an anchor tag you can create hover effects just by changing the opacity of the image.

#imghover a:hover img { filter: alpha(opacity=50);filter: progid:DXImageTransform.Microsoft.Alpha(opacity=50);-moz-opacity: .5;opacity:0.5; }

Affects this HTML:

<div id=”imghover”>
<a href=”#”><img src=”http:///csshook.com/images/one.png” alt=”next” style=”width:24px;height:24px;border:none;” /></a>
</div>

Share/Save/Bookmark

  • No Related Post

 

Introduction to CSS3

Category: CSS, CSS Tips, CSS3 Tutorial    |    679 views    |    Add a Comment  |   

 

What is it?

CSS3 offers a huge variety of new ways to create an impact with your designs, with quite a few important changes. This first tutorial will give you a very basic introduction to the new possibilities created by the standard.

Modules

The development of CSS3 is going to be split up into ‘modules’. The old specification was simply too large and complex to be updated as one, so it has been broken down into smaller pieces - with new ones also added. Some of these modules include:

  • The Box Model
  • Lists Module
  • Hyperlink Presentation
  • Speech Module
  • Backgrounds and Borders
  • Text Effects
  • Multi-Column Layout

Read more…

Share/Save/Bookmark

 

Write a Clean CSS

Category: CSS, CSS Tips, CSS3 Tutorial    |    638 views    |    3 Comments  |   

 

Grouping Your Styles

Group your styles into categories (ex. layout, typography, forms, so on) and visually seperate them in your css file. A title and table of contents doesn’t hurt either:

/*
	csshook.com Screen Styles

	Table of Contents:
		layout
		typography
		forms
*/

/* layout
----------------------------------------------- */

/* typography
----------------------------------------------- */

/* forms
----------------------------------------------- */

Choosing Your Categories

Even though I do have some common practices, I don’t have a ‘template’ for how to breakdown styles into categories.

For starters, I almost always have layout and typography categories. Withtypography defining the sitewide look and feel. Depending on the complexity, I may break out the table and form styles into their own categories.

Next, I address the physical sections of the page with their own categories:headersidebarcontent, and footer for example. Lastly, I collect the page and content section specific styles and place them in their own category (and sometimes subcategories).

Importing Stylesheets

Another method is to categorize the styles and place them in seperate CSS files which are all imported by one main CSS file. I find this method good in theory but it can lead to overlapping styles, specification issues, and general confusion if you’re not very careful:

@import url("layout.css");
@import url("typography.css");
@import url("forms.css");

Linebreaks and Indenting Read more…

Share/Save/Bookmark

 

How to create Rounded Corners Using CSS without Images

Category: CSS, CSS Tips, CSS3 Tutorial    |    1,404 views    |    Add a Comment  |   

 

The Basics of Rounded Corners

Rounded corners rely on the fact that computer monitors and our eyes are not that good at viewing what are effectively tiny squares (the pixels). So if you set up a series of pixels along the edges of your elements, you can line them up in such a way that they make the box they are edging appear to have rounded edges. For example, this page demonstrates how you can set up rounded corners on various div elements.

To create the rounded corners, you need an inline element that acts as the actual pixel for your corner. This could be any inline element, but I prefer either the span element or the b element. Span because it’s probably the most “correct” element to use, and b because it’s shorter to type and you should be using strong for your bolded text.

The XHTML Required for Rounded Corners

 

<div class=”container”>
<b class=”rtop”><b class=”r1?></b> <b class=”r2?></b> <b class=”r3?></b> <b class=”r4?></b></b>
CONTENTS GOES HERE
<b class=”rbottom”><b class=”r4?></b> <b class=”r3?></b> <b class=”r2?></b> <b class=”r1?></b></b>
</div>

In order for your corners to show up, you need to have your container div be a different color than the background color of the page. So, the first thing your style sheet should have is a style indicating what color your rounded elements will be:

.container {
background:#ccc;
color:#fff;
margin:0 15px;
}

As you can see, I also set the left and right margins a little off the edges so that they would be easier to see the rounded corners. Read more…

Share/Save/Bookmark

 

Difference Between CSS and XSLT

Category: CSS 2 Tutorial, CSS Tips    |    647 views    |    3 Comments  |   

 

Cascading Style Sheets or CSS were developed a few years ago to define the look and feel of markup languages. Extensible Style Sheet Language for Transformations or XSLT were created to transform documents. They are both style sheets, but they serve vastly different purposes.

What CSS Can Do

  • Modify the font size, color, family, and style of text in markup
  • Define the location and size of an element
  • Change the background image and color of elements
  • Create a new look and feel for markup pages to display on the Web

 

What CSS Cannot Do

  • Change the order of elements in a document
  • Make computations based on the content of the document
  • Add content to the document
  • Combine multiple documents into one

 

XSLT is a powerful language for transforming documents. It was created to allow developers the ability to create data and then transform it to various different formats. It is meant to keep the distinction between content and design separate. Read more…

Share/Save/Bookmark

 

Explaining CSS Positioning

Category: Articles, CSS Tips, CSS3 Tutorial    |    747 views    |    2 Comments  |   

 

When you’re going to use CSS positioning, the first thing you need to do is use the CSS property position to tell the browser if you’re going to use absolute or relative positioning.

What most people don’t realize when they’re using CSS to lay out Web pages is that there are actually four states to the position property:

  • static
  • absolute
  • relative
  • fixed

Static is the default position for any element on a Web page. If you don’t define the position, it will be static and will display on the screen based on where it is in the HTML document and how it would display inside thenormal flow of the document.

If you apply positioning rules like top or left to an element that has a static position, those rules will be ignored.

Absolute CSS Positioning

Absolute positioning is the easiest to understand. You start with the CSS position property:

position: absolute;

This tells the browser that whatever is going to be positioned should be removed from the normal flow of the document and will be placed in an exact location on the page. It is also taken out of the normal flow of the document - it won’t affect how the elements before it or after it in the HTML are positioned on the Web page. Read more…

Share/Save/Bookmark

 

What is CSS Sprite?

Category: CSS, CSS Tips, CSS Tutorials    |    700 views    |    1 Comment  |   

CSS Sprites is a technique by which we can combine multiple images in a single big image and position the various parts of this big image with our elements u

sing pure CSS attributes. The primary objective behind using CSS Sprites is to decrease the number of HTTP requests and thus decreasing the request stress on server. The idea behind CSS Sprites is to consolidate multiple images into one sprite and then selectively display portions of this sprite with positioning. It starts by creating a larger CSS Sprite by grouping more than one images (usually icons) together and aligning them in proper grid style to aid the positioning. Then it is aligning used a proper positioning values on the webpages to show their respective images. This way it decreases the number of HTTP requests and thus increases the overall speed of webpages.

Sometimes back, we used the favourite slicing technique to break down a larger image into smaller slices (parts) so as to make pages load faster, but all this technique was only fooling our eyes as the page looked like loading faster, while in reality it was not. Each of those images was fed up as a separate request to the server and would increase the time of loading actually.

According to Yahoo UI blog, the resultant sprite created by joining smaller images is always smaller in size than the combined contributed parts. It is because we have to use a single color table for the sprite instead of individual color tables for the contributed ones. Another advantage of using sprites is that this way we save the overhead required by the images.

How do CSS Sprites work?

As it turns out, the basic tools to do this are built into CSS, given a bit of creative thinking.

Let’s start with the master image itself. Dividing a rectangle into four items, you’ll observe in this master image that our intended “before” link images are on the top row, with “after”:hover states immediately below. There’s no clear division between the four links at the moment, so imagine that each piece of text is a link for now. (For the sake of simplicity, we’ll continue to refer to link images as “before” images and the :hover state as “after” for the rest of this article. It’s possible to extend this method to :active:focus, and :visitedlinks states as well, but we won’t go into that here.)

Those familiar with Petr Stanicek’s (Pixy) Fast Rollovers may already see where we’re going with this. This article owes a debt of gratitude to Pixy’s example for the basic function we’ll be relying on. But let’s not get ahead of ourselves.

On to the HTML. Every good CSS trick strives to add a layer of visuals on top of a clean block of code, and this technique is no exception:

  <ul id="skyline">
    <li id="panel1b"><a href="#1"></a></li>
    <li id="panel2b"><a href="#2"></a></li>
    <li id="panel3b"><a href="#3"></a></li>
    <li id="panel4b"><a href="#4"></a></li>
  </ul>

This code will serve as a base for our example. Light-weight, simple markup that degrades well in older and CSS-disabled browsers is all the rage, and it’s a trend that’s good for the industry. It’s a great ideal to shoot for. (We’ll ignore any text inside the links for the time being. Apply your favorite image replacement technique later to hide the text you’ll end up adding.) Read more…

Share/Save/Bookmark

 

How to Div Horizontal And Vertical Centering

Category: CSS, CSS Tips, CSS3 Tutorial    |    2,785 views    |    Add a Comment  |   

 

I know many people have wondered how to center their content both horizontally and vertically but never managed to find a solution on how to do this using CSS. I have seen people use tables to accomplish this, in this tutorial I will show you how it can be done.

We start off by using an IE (Internet Explorer) hack to make the height of the page 100%.

html, body {
height: 100%;
}

The next part of the code is to give our element an ID. You may find it easier to put whatever content you want centring inside a div tag, I find this works a lot easier, in the end it’s up to you.

CSS Code

<style type=”text/css”>
html, body {
height: 100%;
 

#centeredcontent {
}
</style>

 

We have our ID assigned, now lets move to our HTML and add the code there in the <body> of your page. Read more…

Share/Save/Bookmark