Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

CSS and webparts

I created a web part page and added a few webparts.  I would like to change it up a bit with CSS but it's not my greatest strenght.

The code below is a section I would like to change.  I want the background-color to be #DDDDDD.

How would I do that in CSS?  I want to put it in a CEWP.

Thanks.
<table TOPLEVEL border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
					<tr class="ms-WPHeader">
						<td title="GA&amp;CKO Directors Hatch - Use for formatted text, tables, and images." id="WebPartTitleWPQ3" style="width:100%;"><h3 class="ms-standardheader ms-WPTitle"><nobr><span>GA&amp;CKO Directors Hatch</span><span id="WebPartCaptionWPQ3"></span></nobr></h3></td><td align="right" style="padding-right:2px"><div style="cursor: pointer" class="ms-HoverCellInActive" onmouseout="this.className='ms-HoverCellInActive'" onmouseover="this.className='ms-HoverCellActiveDark'"><nobr><a onclick="MSOWebPartPage_OpenMenu(MSOMenu_WebPartMenu, this, WebPartWPQ3,&#39;False&#39;);return false;" id="WebPartWPQ3_MenuLink" onkeydown="MSOMenu_KeyboardClick(WebPartWPQ3_MenuLink, 13, 40)" href="#"><img src="/_layouts/images/Menu1.gif" border="0" align="absmiddle" title="GA&amp;CKO Directors Hatch Web Part Menu" alt="GA&amp;CKO Directors Hatch Web Part Menu" style="padding-left:2px;" /></a></nobr></div></td>
					</tr>
				</table></td>
			</tr><tr>
				<td class="" valign="top"><div WebPartID="f9df9cbc-adb4-4224-91e6-d6ffa9bf57ea" HasPers="false" id="WebPartWPQ3" width="100%" class="ms-WPBody" allowDelete="false" style="" ><P align=center><FONT color=#000040 size=6><STRONG>The Director's Page</STRONG></FONT></P></div></td>
			</tr>
		</table>

Open in new window

Avatar of svetaye
svetaye
Flag of Israel image

Hello,
To overwrite the CSS style for this table you need something to identify this table.Something like "id" or "name" or "class". You don't have any of them so as long as there no parent selectors in CSS you need to find any element that containf this table and have an "id" or "name" or "class" attribute.

Example:
<div id="webpartzone">
The code you have been posted
</div>

In other words : please post  here 10 additional lines of your source code that comes before the code you've been posted here before.
Avatar of Isaac

ASKER

Luckily, I just needed to add 1 line above what I posted.
<td id="MSOZoneCell_WebPartWPQ3" vAlign="top">
<table TOPLEVEL border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td><table border="0" cellpadding="0" cellspacing="0" width="100%">
					<tr class="ms-WPHeader">
						<td title="GA&amp;CKO Directors Hatch - Use for formatted text, tables, and images." id="WebPartTitleWPQ3" style="width:100%;"><h3 class="ms-standardheader ms-WPTitle"><nobr><span>GA&amp;CKO Directors Hatch</span><span id="WebPartCaptionWPQ3"></span></nobr></h3></td><td align="right" style="padding-right:2px"><div style="cursor: pointer" class="ms-HoverCellInActive" onmouseout="this.className='ms-HoverCellInActive'" onmouseover="this.className='ms-HoverCellActiveDark'"><nobr><a onclick="MSOWebPartPage_OpenMenu(MSOMenu_WebPartMenu, this, WebPartWPQ3,&#39;False&#39;);return false;" id="WebPartWPQ3_MenuLink" onkeydown="MSOMenu_KeyboardClick(WebPartWPQ3_MenuLink, 13, 40)" href="#"><img src="/_layouts/images/Menu1.gif" border="0" align="absmiddle" title="GA&amp;CKO Directors Hatch Web Part Menu" alt="GA&amp;CKO Directors Hatch Web Part Menu" style="padding-left:2px;" /></a></nobr></div></td>
					</tr>
				</table></td>
			</tr><tr>
				<td class="" valign="top"><div WebPartID="f9df9cbc-adb4-4224-91e6-d6ffa9bf57ea" HasPers="false" id="WebPartWPQ3" width="100%" class="ms-WPBody" allowDelete="false" style="" ><P align=center><FONT color=#000040 size=6><STRONG>The Director's Page</STRONG></FONT></P></div></td>
			</tr>
		</table> 
</td>

Open in new window

Actually you need more because this "id" is dynamically generated id and can be changed if you will replace your web part in the feature. But we can do the trick with this dynamic id for now.
Please try this code for your CEWP:

this will set the background color for your table cells:
<style type="text/css">
#MSOZoneCell_WebPartWPQ3 table td
{
 background-color:#DDDDDD;
}
</style>

Open in new window


and this will set the set the background color for whole cell that contains your table:
<style type="text/css">
#MSOZoneCell_WebPartWPQ3
{
 background-color:#DDDDDD;
}
</style>

Open in new window

Avatar of Isaac

ASKER

It works but it's not working....here's what I mean

The following does not work:
<style type="text/css">
#MSOZoneCell_WebPartWPQ3
{
 background-color:#DDDDDD;
}
</style>

This works:
<style type="text/css">
#MSOZoneCell_WebPartWPQ3
{
 background-color:red;
}
</style>
ASKER CERTIFIED SOLUTION
Avatar of svetaye
svetaye
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Isaac

ASKER

Thanks!  Is there a reasone why #DDDDDD did not work.
The only issue I can think about is the monitor issue.
Maybe you just can't see this color because it's too light on your display. Maybe you are working on the server via Remote Desktop?
This also can show you wrong colors.
Avatar of Isaac

ASKER

THANKS!