Re: css question

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Put the image inside a div with the div's width style set to "1px", and its'
left-margin and right-margin styles set to "auto". Put the div inside the
div you want to center the image in. The inner div will stretch its' width
to accomodate the image and be centered in the outer div.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

"Tem" <tem1232@xxxxxxxxx> wrote in message
news:eATD6KWIIHA.1164@xxxxxxxxxxxxxxxxxxxxxxx
Thanks. how do I center the image in the div?

"Kevin Spencer" <unclechutney@xxxxxxxxxxxx> wrote in message
news:OBmMmZTIIHA.4688@xxxxxxxxxxxxxxxxxxxxxxx
If you had tried Nick's suggestion, you would have seen that this is
exactly what it does.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

"Tem" <tem1232@xxxxxxxxx> wrote in message
news:ewLEByLIIHA.4688@xxxxxxxxxxxxxxxxxxxxxxx
That won't work because I need to set the width of the image, 80% of the
width of the parent element, the div.
Can this be done with CSS?

"Nick Chan" <zzzxtreme@xxxxxxxxx> wrote in message
news:1194345302.205603.6240@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
could u do something like this?

<div class="a1" style="width:100%"><img src="test.jpg" style="width:
80%" /></div>


On Nov 6, 1:22 pm, "Tem" <tem1...@xxxxxxxxx> wrote:
Is this possbile with css or do I need to use javascript? If so how?

<div class="a1" style="width:100%"><img src="test.jpg" /></div>

The width of the div is a variable. Can I scale the img accordingly?
img width is 80% of the width of the div

Tem








.



Relevant Pages

  • Re: RegEx substring
    ... Kevin Spencer wrote: ... This uses a positive LookBehind and a positive LookAhead. ... In addition, a div may have attributes, so I added an expression to the ...
    (microsoft.public.dotnet.framework)
  • Re: Make cells in Table webcontrol clickable?
    ... A System.Web.UI.WebControls.Panel object renders a div on the client. ... "Paul W" wrote in message ... > a panel control to the tablecell's control collection? ... > "Kevin Spencer" wrote in message ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: css question
    ... "Kevin Spencer" wrote in message ... "Tem" wrote in message ... width of the parent element, ... The width of the div is a variable. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: size a DIV as large as needed to fit contents
    ... It will expand horizontally to fit its container. ... But that only seems to work for height, the width of my DIV ... > "Kevin Spencer" wrote in message ... >> Microsoft MVP ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: css question
    ... Kevin Spencer ... Chicken Salad Surgeon ... width of the parent element, ... The width of the div is a variable. ...
    (microsoft.public.dotnet.framework.aspnet)