-

2011年8月3日星期三

CSS class not working?

-I'm working on a website and I want to apply a few different things like margin and background and a border to only one image on my page. Naturally, I figured I would use a class feature on my CSS. However, the class doesn't seem to do anything at all. I'm not sure why and I can't seem to find an answer on the web. Here is the CSS used:



img.itemhead {

margin-left: 200px;

border: 3px;



}



And the page so you can see the whole thing:

http://parachutemagazine.com/bill/item2.鈥?/a>



Hopefully someone can help me! I'm making this for someone who's practically computer illiterate, so I want to keep as much in the CSS/Javascript as possible while still getting the features I want.The margin style defined in "#main img" is overriding the margin style in the itemhead class.

Declare the 'itemhead' class like so in your stylesheet:



#main img.itemhead {

margin-left: 200px;

border: 3px;

}No problem with CSS, but you may have forgotten to add the class to the image tag you want to style:



<img class="itemhead" style="width: XXpx; height: YYpx; border: 0;" src="Path to image" alt="Text Description">



CSS could include stuff in style attribute:



img.itemhead {

width: XXXpx;

height: YYYpx;

border: 0;

margin-left: 200px;

border: 3px;

}



Then HTML could be:



<img class="itemhead" src="Path to image" alt="Text Description">



Ron
w3schools.com



net.tutsplus.com

没有评论:

发表评论