Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Old 06-02-2007, 04:40 AM Another CSS tip
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,023
Name: Forrest Croce
Location: Seattle, WA
Trades: 0
There's another great thread gonig on about how to examine external CSS and JS files on a site, to get an idea how somebody else approached a given problem. Not wanting to hijack that thread, I'd still like to share a CSS tip that I've known about forever, but never had much use for ... I redesigned my site, and all of a sudden this style of coding is extremely helpful.

In my main html, I have this code:

<a href="../Galleries/Vancouver.html" class="web812l mainPhoto">
...<img src="../Images/NorthVancouver.jpg" alt="North Vancouver from Stanley Park" />
</a>

By default my photos are 8x12 inches, but plenty of them get cropped to 8x10, and there's landscape and portrait orientation - which kind of sideways. Anyway, let's look at the CSS involved:

.web812l {
...background-repeat: no-repeat;
...background-position: center;
...display: block;
...width:850px;
...height:585px;
...background-image:url(/GraphicElements/web812l.png);
...position:relative;
...float: left;
}

.mainPhoto { margin-left: 100px; }

Now, I could have accomplished the same thing by setting mainPhoto as the ID and not a class, but there are pages ( like Twin Falls ) set up to display two photos. More to the point, I don't know how many classes you can assign to a particular element, but it's plural ... more than one.

This can help you repeat less in your CSS, but more importantly, it can let you create classes that are more meaningful, so build a web site that's easier to maintain.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
 
Register now for full access!
Old 06-02-2007, 05:40 AM Re: Another CSS tip
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I have some elements with 4 classes applied in a single attribute.

All the modern browsers support multiple classes but some very old ones may not.

3 page article on Multiple CSS Classes and reducing page size at WebReference that I have had in my "favourites list" from long ago
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-05-2007, 02:41 AM Re: Another CSS tip
seolman's Avatar
Super Spam Talker

Latest Blog Post:
What are Canonical Links?
Posts: 769
Name: DaveBob Roundpants III
Location: Heredia, Costa Rica
Trades: 0
Quote:
Originally Posted by chrishirst View Post
I have some elements with 4 classes applied in a single attribute.

All the modern browsers support multiple classes but some very old ones may not.

3 page article on Multiple CSS Classes and reducing page size at WebReference that I have had in my "favourites list" from long ago
Thanks for this link. Very nice info on multiple CSS classes. Just to be nosy I visited the authors web sites - the source code is art.
__________________
"So they have the Internet on computers now?"
Please login or register to view this content. Registration is FREE

seolman is offline
Reply With Quote
View Public Profile Visit seolman's homepage!
 
Old 06-05-2007, 06:47 PM Re: Another CSS tip
angele803's Avatar
Perfectly Imperfect

Posts: 1,774
Name: Stephanie
Location: Oklahoma
Trades: 2
cool. I was wondering if you could use multiple classes and how you would use them.
Thanks!
angele803 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Another CSS tip
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14809 seconds with 12 queries