?
Solved

CSS and webparts

Posted on 2011-10-03
8
Medium Priority
?
808 Views
Last Modified: 2012-05-12
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

0
Comment
Question by:Isaac
  • 4
  • 4
8 Comments
 
LVL 11

Expert Comment

by:svetaye
ID: 36903925
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.
0
 
LVL 5

Author Comment

by:Isaac
ID: 36904324
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

0
 
LVL 11

Expert Comment

by:svetaye
ID: 36904659
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

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:Isaac
ID: 36905303
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>
0
 
LVL 11

Accepted Solution

by:
svetaye earned 2000 total points
ID: 36905329
What about this:
<style type="text/css">
#MSOZoneCell_WebPartWPQ3
{
 background-color:#C1C1C1;
}
</style>
0
 
LVL 5

Author Comment

by:Isaac
ID: 36910085
Thanks!  Is there a reasone why #DDDDDD did not work.
0
 
LVL 11

Expert Comment

by:svetaye
ID: 36910188
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.
0
 
LVL 5

Author Closing Comment

by:Isaac
ID: 36910581
THANKS!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question