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
Tidying up the following code
Old 12-07-2010, 09:37 AM Tidying up the following code
shonkyboy's Avatar
Extreme Talker

Posts: 226
Name: Chris
Location: West Yorks , UK
Trades: 0
Hi i have a list of cocktails- and each cocktail has a different image assigned to it at the right of its container - what would be the most standards freindly and least footprint way to orgainise the following code please

Code:
     .rightimg-icedtea { float: right;
background:url(images/iced-teas.png);
     height: 65px; width: 50px;
     background-repeat:no-repeat;
     margin-top: 10px; }
so i could have say classic, mojitos, fizz, specials ect - without repeating the whole block for every one ?

Essentially they are all the same - but the image changes for each one.
i sort of thought of defining .rightimg then say .icedtea, .classic etc - but am a little unsure the best way to go about this.
TIA.
__________________

Please login or register to view this content. Registration is FREE

Last edited by shonkyboy; 12-07-2010 at 09:39 AM..
shonkyboy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-07-2010, 09:41 AM Re: Tidying up the following code
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,376
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
define a global class rule for the containers then set the background image using the ID.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-07-2010, 10:07 AM Re: Tidying up the following code
shonkyboy's Avatar
Extreme Talker

Posts: 226
Name: Chris
Location: West Yorks , UK
Trades: 0
what code would you use for that chris? i have to be a bit careful here you see as its a Joomla template im using on this particular project and they have a tendancy to conflict on the cascade in some cases.
__________________

Please login or register to view this content. Registration is FREE
shonkyboy is offline
Reply With Quote
View Public Profile
 
Old 12-07-2010, 10:31 AM Re: Tidying up the following code
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,376
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Code:
.rightimg {
     float: right;
     height: 65px;
     width: 50px;
     background-repeat:no-repeat;
     margin-top: 10px;
}
#icedtea {
    background-image:url(images/iced-teas.png);
}
HTML Code:
<div id="icedtea" class="rightimg"></div>
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-07-2010, 10:35 AM Re: Tidying up the following code
shonkyboy's Avatar
Extreme Talker

Posts: 226
Name: Chris
Location: West Yorks , UK
Trades: 0
ah ok chris - thanks for that - i sort of thought of doing it similar that way but thought it may be a case of divitis - but it would certainly work - ill give it a try thanks
__________________

Please login or register to view this content. Registration is FREE
shonkyboy is offline
Reply With Quote
View Public Profile
 
Old 12-07-2010, 10:48 AM Re: Tidying up the following code
CSM
CSM's Avatar
Front-End Developer

Posts: 297
Name: Michael Pehl
Location: Palma de Mallorca
Trades: 0
LOL that's for sure not a case of DIVitis

It makes sense... but I would go another way (think of SEO, too).

Instead of using

Code:
.rightimg {
     float: right;
     height: 65px;
     width: 50px;
     background-repeat:no-repeat;
     margin-top: 10px;
}
#icedtea {
    background-image:url(images/iced-teas.png);
}
I would only use

Code:
.rightimg {
     float: right;
     height: 65px;
     width: 50px;
     background-repeat:no-repeat;
     margin-top: 10px;
}
and would use this markup:

Code:
<div class="rightimg"><img src="path/to/image.jpg" width="50" height="65" alt="image alt" title="The Image Cocktail" /></div>
__________________
Chief Web Officer / Front-End Developer / System Engineer

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
CSM is offline
Reply With Quote
View Public Profile Visit CSM's homepage!
 
Old 12-12-2010, 07:10 AM Re: Tidying up the following code
c69
c69's Avatar
Experienced Talker

Posts: 40
Name: Constantine
Trades: 0
offtopic:
50x65 ? that doesn't look like an image, but rather like an icon / bullet. Do not use image for it, stick to Chris' solution.
c69 is offline
Reply With Quote
View Public Profile Visit c69's homepage!
 
Old 12-13-2010, 11:56 PM Re: Tidying up the following code
Banned

Posts: 143
Name: maheshadodis
Location: USA
Trades: 0
Hi,
Can i have some screen shot or site link to see what is the problem ??
maheshadodis is offline
Reply With Quote
View Public Profile
 
Old 12-14-2010, 02:53 PM Re: Tidying up the following code
Novice Talker

Posts: 7
Trades: 0
im joining maheshadodis' request.
__________________
If you are looking for
Please login or register to view this content. Registration is FREE
you can always search google. However, for more
Please login or register to view this content. Registration is FREE
I would suggest going to my website.
I'm also looking to exchange links, PM me if interested.
Ornani is offline
Reply With Quote
View Public Profile
 
Old 12-14-2010, 03:54 PM Re: Tidying up the following code
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,376
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by c69 View Post
offtopic:
50x65 ? that doesn't look like an image, but rather like an icon / bullet. Do not use image for it, stick to Chris' solution.
"images" can range from a single pixel upwards, So no matter what size it is it will still be an image.

A 16x16 "favicon" is still an image.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-14-2010, 03:55 PM Re: Tidying up the following code
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,376
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by maheshadodis View Post
Hi,
Can i have some screen shot or site link to see what is the problem ??
Quote:
Originally Posted by Ornani View Post
im joining maheshadodis' request.
Why??

If you look at the nature of the question and the OP can provide a link that shows what is required the issue would be solved!
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Tidying up the following code
 

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.41547 seconds with 12 queries