473,396 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Mystified by CSS IMG Problem

Jim
Hi,

I am hoping that someone here can help me out on this.

The following code works just fine and gives me a nice margin between
my image to the left and the text that appears adjacent to it on the
right:

<p>Figure 2. xxxx</p>
<img style="float:left; margin-right:14px; margin-bottom:8px;"
src="pic.jpg" width="128" height="473" alt="pic" />
<p>This is a paragraph of text.....</p>

Now I take that inline CSS and add it to my style sheet as follows:

img.ileft {float:left; margin-right:14px; margin-bottom:8px;}

and then use the following HTML:

<p>Figure 2. xxxx</p>
<img class="ileft" src="pic.jpg" width="128" height="473" alt="pic" />
<p>This is a paragraph of text.....</p>

What happens is that while my text still displays to the right of my
image (obviously the float attribute still works), the nice margin
between the image and my text disappears (margin-right fails but as
far as I can tell, margin-bottom still works).

Any ideas? Thanks.

PS. Please reply to the list as the email address is a fake to foil
spammers.


Best Regards, Jim
http://artsnova.com/blog
Jan 18 '08 #1
8 3485
Jim wrote:
Hi,

I am hoping that someone here can help me out on this.

The following code works just fine and gives me a nice margin between
my image to the left and the text that appears adjacent to it on the
right:

<p>Figure 2. xxxx</p>
<img style="float:left; margin-right:14px; margin-bottom:8px;"
src="pic.jpg" width="128" height="473" alt="pic" />
<p>This is a paragraph of text.....</p>

Now I take that inline CSS and add it to my style sheet as follows:

img.ileft {float:left; margin-right:14px; margin-bottom:8px;}

and then use the following HTML:

<p>Figure 2. xxxx</p>
<img class="ileft" src="pic.jpg" width="128" height="473" alt="pic" />
<p>This is a paragraph of text.....</p>

What happens is that while my text still displays to the right of my
image (obviously the float attribute still works), the nice margin
between the image and my text disappears (margin-right fails but as
far as I can tell, margin-bottom still works).
The odds are very high that it has something to do with the rest of your
code, but since you haven't given us a way to see it, it's hard to tell.
>
Any ideas? Thanks.

PS. Please reply to the list as the email address is a fake to foil
spammers.
Responding to the newsgroup is the norm.
Jan 18 '08 #2
Scripsit Jim:
The following code
Where's the URL?
PS. Please reply to the list
Where else?
as the email address is a fake to foil spammers.
Thanks for the hint. Please don't change the forged From field before
you have a clue.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jan 18 '08 #3
Jim
Hello Jukka,

On Fri, 18 Jan 2008 19:16:09 +0200, "Jukka K. Korpela"
<jk******@cs.tut.fiwrote:
>Scripsit Jim:
>The following code

Where's the URL?

No URL because it is not online.

>
>PS. Please reply to the list

Where else?

There are folks out there who do attempt to respond offlist. Hence
the explicit statement.

>
>as the email address is a fake to foil spammers.

Thanks for the hint.

You're welcome.

Please don't change the forged From field before
you have a clue.

A clue about what?

Best Regards, Jim
http://artsnova.com/blog
Jan 18 '08 #4
Jim wrote:
>>
Where's the URL?


No URL because it is not online.
Hi Jim,

The reason you're not getting any help is because you haven't provided
enough information for us to help you. If you put what you have up
somewhere and give us the URL, even on some kind of crappy free hosting
site, then we can help you figure out what's wrong. Posting bits and bobs
of code doesn't help. No context. Could be one of any number of things
that you haven't thought of that are causing your problem.

Cheers
Jan 19 '08 #5
Jim <Fa*********@astrodigitalNOT.orgwrites:
On Fri, 18 Jan 2008 10:25:53 -0500, Harlan Messinger
<hm*******************@comcast.netwrote:
>>Jim wrote:
<snip>
>>Now I take that inline CSS and add it to my style sheet as follows:

img.ileft {float:left; margin-right:14px; margin-bottom:8px;}

and then use the following HTML:

<p>Figure 2. xxxx</p>
<img class="ileft" src="pic.jpg" width="128" height="473" alt="pic" />
<p>This is a paragraph of text.....</p>

What happens is that while my text still displays to the right of my
image (obviously the float attribute still works), the nice margin
between the image and my text disappears (margin-right fails but as
far as I can tell, margin-bottom still works).

The odds are very high that it has something to do with the rest of your
code, but since you haven't given us a way to see it, it's hard to tell.

Hmmm. Well the image does appear within a DIV and I do have the
following line of code related to images in that DIV:

.contentblock img {margin-right:auto; margin-left:auto; }
Ah! We needed to see this.
I had thought about inheritance but I am specifically stating that the
image in question is to use the class ILEFT and I would think that
trumps all.

Am I wrong on this?
Yes. Look up the rules on specificity of selectors in:
http://www.w3.org/TR/1998/REC-CSS2-1...2/cascade.html
(but read the whole thing if you can).

Your img.ileft rule has lower specificity than the one you did not show
us at first.

--
Ben.
Jan 19 '08 #6
Jim
Hello Ben,

On Sat, 19 Jan 2008 16:03:14 +0000, Ben Bacarisse
<be********@bsb.me.ukwrote:
>Jim <Fa*********@astrodigitalNOT.orgwrites:
>On Fri, 18 Jan 2008 10:25:53 -0500, Harlan Messinger
<hm*******************@comcast.netwrote:
>>>Jim wrote:
<snip>
>>>Now I take that inline CSS and add it to my style sheet as follows:

img.ileft {float:left; margin-right:14px; margin-bottom:8px;}

and then use the following HTML:

<p>Figure 2. xxxx</p>
<img class="ileft" src="pic.jpg" width="128" height="473" alt="pic" />
<p>This is a paragraph of text.....</p>

What happens is that while my text still displays to the right of my
image (obviously the float attribute still works), the nice margin
between the image and my text disappears (margin-right fails but as
far as I can tell, margin-bottom still works).

The odds are very high that it has something to do with the rest of your
code, but since you haven't given us a way to see it, it's hard to tell.

Hmmm. Well the image does appear within a DIV and I do have the
following line of code related to images in that DIV:

.contentblock img {margin-right:auto; margin-left:auto; }

Ah! We needed to see this.
>I had thought about inheritance but I am specifically stating that the
image in question is to use the class ILEFT and I would think that
trumps all.

Am I wrong on this?

Yes. Look up the rules on specificity of selectors in:
http://www.w3.org/TR/1998/REC-CSS2-1...2/cascade.html
(but read the whole thing if you can).

Your img.ileft rule has lower specificity than the one you did not show
us at first.

Grumble grumble. And I thought I knew CSS.

Ben: thanks for pointing out the w3.org page. I've gone through it but
it seems to me that the margin in ileft should have higher specificity
than the one in contentblock based on my reading of:
http://www.w3.org/TR/1998/REC-CSS2-1...ml#specificity

I think I'll try adding the !important declaration to ileft and see if
that has any impact.

Thanks again Ben.

Best Regards, Jim
http://artsnova.com/blog
Jan 20 '08 #7
Jim
Hi Nik,

On Sat, 19 Jan 2008 16:21:43 +1300, "Nik Coughlin"
<nr******@gmail.comwrote:
>Jim wrote:
>>>
Where's the URL?


No URL because it is not online.

Hi Jim,

The reason you're not getting any help is because you haven't provided
enough information for us to help you. If you put what you have up
somewhere and give us the URL, even on some kind of crappy free hosting
site, then we can help you figure out what's wrong. Posting bits and bobs
of code doesn't help. No context. Could be one of any number of things
that you haven't thought of that are causing your problem.

Cheers

You make a very good point. I've been on the other side of this sort
of thing in the past so hear exactly what you're saying.

Fortunately I think Ben hit the nail on the head in that the problem
is with my misunderstanding the hierachy of inheritance.

Thanks for taking the time to respond to my post.


Best Regards, Jim
http://artsnova.com/blog
Jan 20 '08 #8
Jim <Fa*********@astrodigitalNOT.orgwrites:
Fortunately I think Ben hit the nail on the head in that the problem
is with my misunderstanding the hierachy of inheritance.
For the record, I said no such thing (though I got a detail wrong)!

Inheritance is probably the most miss-understood thing in CSS but I
know enough to know that is has nothing to do with your problem.
Inheritance kicks in only when no CSS rules specify a value for a
property, or when the rule that *does* apply gives "inherit" as the
property value. Neither is the case here.

--
Ben.
Jan 20 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ben Thomas | last post by:
Hi all, I'm having some trouble understanding the behavior of std::ostringstream. (I'm using Visual Studio .Net & STL port 4.5.3). I'll appreciate if someone can give me a little explanation of...
117
by: Peter Olcott | last post by:
www.halting-problem.com
3
by: Paul Wake | last post by:
http://www.xmission.com/~wake/section27.html now works for me in IE/Win but not in Mozilla/Win (my PowerBook is dead and I'm now using my mother-in-law's PC, which limits my options for checking...
12
by: Chad | last post by:
This was taken from the following: http://groups.google.com/group/comp.lang.c/browse_thread/thread/089dfb62c71802b3/663e9afae83d061c?hl=en#663e9afae83d061c And I quote: "Well, that's also ok...
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
2
by: Mike Collins | last post by:
I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. It was asked by someone else what the autopostback was...
8
by: turnitup | last post by:
var body = "blah"; document.getElementById("messagebody").innerHTML = body.toString(); results in syntax error!!!! Any ideas?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.