View Full Version : <object> tag and css width

Jul 3rd, 2009, 04:58 PM
Hi guys,

I'm having a bit of a problem here that seems... well... stupid. I really hope you can help me out.

I'm trying to insert a .swf-file on my website with the object-tag (no problem here, it shows up, plays and everything!). The problem is that I need to be able to control its size in cm rather than pixels due to the quality of the pictures in the swf-movie. If I set the size in pixels, then the quality gets all screwed up.
With standard pictures I usually solve this with css, creating a class that controls the image's size, but I can't for the life of me figure out how to make this work with the <object> tag.

Do you guys have any ideas what to do?


Jul 3rd, 2009, 05:58 PM
Hey deafdigit,

I believe the problem lies within the swf. I've never heard of specifying anything by cm.

If the SWF wasn't created by you (ie. a flash game or a banner), it was created to be a certain dimension. The dimensions you are specifying are probably distorting its quality because it has to stretch a little to fit your code.

If the SWF was created by you, I recommend resizing it to fit your dimensions so your code doesn't have to stretch the movie and mess with the quality.

Hope this helps.

Jul 3rd, 2009, 06:41 PM
Hi Jrp1,

Thanks for your (frightningly) quick reply ;)

The file IS created by myself. Perhaps the problem lies deeper than so, but as this is a CSS-forum, I don't know if this is really the right place to post it... ahh well nil desperandum! Here goes anyway...

The swf-file contains a slowly changing picture of a person (the one I'm creating the website for). The photo I have of him is huge... no no... it's HUGE! Also it's in extremely high quality. The problem seems to be that when I put it into Flash and resize it to fit the size that the movies has on the website, the quality gets all screwed up.
I've found (by means of tedious trial-and-error) that if I don't run the image through Flash and just puts it on the website via a <img src...> tag and then make a CSS-class containing amongst other things "width: 18cm;", then the image shrinks to the desired size AND it keeps its good quality.
So - back to the question in the first post: I can't seem to figure out how to assign a class to a <object> tag.

This is what I do with images:
<img src='path/file.type' class='imgstyle'>

But this doesn't work with objects, apparently:
<object class='imgstyle'>

... no matter how I define the class in the header.

I hope I'm making more sense this time :)


Jul 3rd, 2009, 07:20 PM
Try resizing it in Photoshop instead. Flash doesn't size pictures very well.

Try this to apply a class to an object:

<span class="class"><object src='url'></span>

Jul 4th, 2009, 11:53 AM
I will, thanks - I'll let you know if it works :)

Jul 5th, 2009, 02:19 PM
It works a treat, bloody amazing.
Thanks a lot jrp1 :)