Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Every one

In my CMS project i have used asp.net menu having text center align. For table i have used text align left for tds.
Now i am having a problem that all my menu text became left align. when i checked the source i found that asp.net menus are also making tds. so to the tds of asp.net menu the default td css design applies.

I am weak in css designing.

Thanks and Regards
TanzeelurRehman
Posted
Comments
[no name] 28-Apr-11 2:14am    
Post your CSS code then we will guide you to sort your problem.
TanzeelurRehman 28-Apr-11 2:30am    
This is the css which i have applied to tds of my project

td
{
text-align:left;
line-height: 150%;
}


For asp.net menus i have used the following css code


MenuTextAlignmentCenter
{
text-align: center;
}


You can check the online version of the project
http://n.fbr.gov.pk/OfficeHomePage.aspx?view=Office%20Home%20Page&ActionID=53&ArticleID=548

Why dont you change the text-alignment to right in the css?
 
Share this answer
 
Comments
TanzeelurRehman 28-Apr-11 2:44am    
Thanks for the response

I am not getting, which one i have to text-align to the right,
Basically i want to left align all the td data through out the project and all the menu items of the asp.net menu to align center. but i dont know it is not working basically i am not able to debug the problem coz my design approach is weak
You need to make more use of the features CSS has to be more selective about what styles get applied to what elements. You can then define styles that don't just affect all tags of a particular type.

CSS selectors can get quite complex, but simple use of classes is a good start.
Something like:

XML
<td class="MyTD">
...
</td>


in your HTML, and

[note the DOT indicating this is a class selector]
C#
.MyTD
{
text-align:left;
}


in your CSS. MyTD is just an identifier for a CSS class - substitute whatever you find descriptive.

W3Schools is a good general resource for CSS, HTML and lots of other web stuff. See http://www.w3schools.com/css/css_reference.asp[^]
 
Share this answer
 
Comments
TanzeelurRehman 28-Apr-11 3:04am    
Thank you for the response

There are no html pages in the project, basically we have an administration section in the project where we are using fckeditor for content writing and we save them in the database. when the data entry operator writing contents in the fck editor, he uses tables, and also he doesnot know about this type of codes. so i need such a solution that all table tds contents accept the tds build by asp.net menu should go left align and the asp.net menu should go center align
NuttingCDEF 28-Apr-11 3:20am    
OK, I'm not familiar with fck editor, but 2 suggestions:

1. How does the content get from the database to a rendered web page? Is there any option for adding class definitions to a DIV tag (or anything else) that wraps a block of content when it is rendered to the web page? I.e. so this is done once by the web designer only. If so, a CSS selector like:

.MyWrapper td
{
...
}

may help.

2. Analyse the resulting HTML and use very specific CSS selectors to identify the menu elements and apply styles to them.

For either of these note that if 2 separate CSS style definitions apply (i.e. CSS selectors for both styles apply to that HTML element) and the elements of the styles conflict, the later of the conflicting elements in the CSS files will override the other.

If you want more help / useful examples, suggest you get hold of the full body tag of a rendered page, edit it down to a menu and a chunk of content (but retaining the full nesting sequence of elements from body tag down to the menu / content) and post it back here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900