CSS class not being used on list item with styling - css

I have a list item thats styled based on the div container it's in. I want to add a "selected" class to that item, but it's not changing the styling. Firebug doesn't show it inhereting any styles from that css style.
You'll see I'm adding class="columnTabSelected" to the first tab, but that's not changing anything.
Here's a screenshot from Firebug to show that style isn't being added to the element.
http://i49.tinypic.com/oszfqh.jpg
What am i missing?
My html
<div id="columnNewsTabs">
<ul>
<li id="recentHeadlinesLink" onclick="columnNews('recentHeadlines')" class="columnTabSelected">Recent</li>
<li id="recentCommentstLink" onclick="columnNews('recentComments')">Comments</li>
<li id="popularHeadlinesLink" onclick="columnNews('popularHeadlines')">Popular</li>
</ul>
</div>
My CSS
#columnNewsTabs {
overflow:auto;
}
#columnNewsTabs ul {
list-style:none;
margin:0px;
padding-left:0px;
}
#columnNewsTabs li {
float:left;
margin-right:2px;
font-family:Tahoma;
font-weight:bold;
padding: 5px;
border:1px solid #ccc;
border-bottom:none;
}
#columnNewsTabs li:hover {
float:left;
margin-right:2px;
color:black;
font-family:Tahoma;
font-weight:bold;
padding: 5px
border:1px solid #ccc;
border-bottom:none;
background:#ccc;
}
#columnTabSelected {
background: #CCCCCC !important;
}

Since you're defining a class and not an id, you need to use the class selector . instead of the id selector #:
#columnTabSelected {
background: #CCCCCC !important;
}
Should be
.columnTabSelected {
background: #CCCCCC !important;
}

You have it as class="columnTabSelected" but your CSS is written as #columnTabSelected. Change that last bit to .columnTabSelected as this represents Classes rather then IDs.

Related

CSS structure changes in html & aspx page

My website shows different output in .aspx page while using same structure & CSS in html page it shows correct output but in apsx page css gets collapse. I check both code twice & it is same but output gets different.
HTML Page Output
ASPX page output
HTML Code
<!--bg-img-container-starts--><div class="bg-img-container">
<!--bg-img-starts--><div class="bg-img">
<!--header-starts--><div class="header">
<!--logo-starts--><div class="logo">
<h2><a title="Quista" href="#">Quista</a></h2>
</div><!--logo-ends-->
<!--menus-starts--><div class="menus">
<ul class="nav">
<li>Home <div class="pipe"></div></li>
<li>Services</li>
<li>Pricing</li>
<li>Track Orders</li>
<li>About Quista</li>
<li class="call">Call Us :- +91 1234 1245</li>
</ul>
</div><!--menus-ends-->
</div><!--header-ends-->
</div><!--bg-img-ends-->
CSS
html, body{
margin:0;
padding:0;
width:100%;
height:100%
}
.clear{clear:both}
body{
font-family:'Quicksand', sans-serif;
}
.bg-img-container{
width:100%;
position:relative;
height:100%
}
.bg-img{
width:100%;
max-height:768px;
height:100%;
background:url(../Images/0000.jpg) no-repeat;
background-size:cover;
}
.header{
width:100%;
max-width:1200px;
position:relative;
margin:0 auto;
padding:15px 0 0 0
}
.logo{
width:20%;
display:inline-block;
}
.logo h2{
font-family:'MyriadPro-BoldCondIt';
font-size:4em;
padding:0;
margin:0;
letter-spacing: 5px
}
.logo a{
color:#fff;
text-decoration:none
}
.menus{
width:79%;
display:inline-block;
}
.nav{
marging:0;
padding:0
}
.nav li{
display:inline-block;
list-style:none:none;
}
.nav li a {
padding:15px 25px 15px 25px;
color:#fff;
text-decoration:none;
display:block
}
.nav li a:hover{
border-bottom:2px solid #FFF
}
.call{
background:#df6b5e;
border-radius:50px
}
.call a{
font-weight:bold;
padding:15px 25px 15px 25px !important
}
.call a:hover{
border:none !important
}
I think problem is with top div (img-bg-container) because in css I have given height 100% & it's child div max:height:768px. Though problem solves if I keep min height instead max height in aspx page but How come it shows diiferent output when codes are same..
Do one thing. Right click on page and and select inspect element. and check both the page html and css. It will be easy to compare and find which css is not working.
Also check the form tag css as we place form tag above all HTML tags and inside body tag in asp.net. Usually HTML page do not have such structure. check and let me know.

apply css to li on click without jquery or javascript

here is my html code
<div id="menus">
<ul>
<li>Home</li>
<li>Users</li>
<li>Project Manage</li>
<li>Transaction</li>
<li style="border-right:none;">Logout</li>
</ul>
</div>
here is my CSS
#menus li
{
float:left;
list-style-type: none;
padding-left: 25px;
padding-right: 25px;
border-right:groove 1px #FFFFFF;
background: #666666;
}
#menus li:hover
{
background: #999999;
}
#menus li a
{
font-size:24px;
text-decoration:none;
color:#FFFFFF;
}
#menus li a:hover
{
color:#000000;
}
now i want to change css when user click on li (like display current selected). can I do this using css only?? If yes then how??
Thanks in advance..
You can do it with CSS only using focus and tabindex
DEMO http://jsfiddle.net/kevinPHPkevin/LstNS/4/
li:focus {
background: red;
outline: 0;
}
A good way to employ an 'active' menu item solution is this
DEMO http://jsfiddle.net/kevinPHPkevin/LstNS/6/
Source: http://www.456bereastreet.com/archive/200503/setting_the_current_menu_state_with_css/
No, you can not do this with just css. I am not too sure what to say...
If you want to have a page specific active, place a different class in the backend, example:

selected css menu style change using css

I have a css menu in my aspx page.I want the selected menu to have the same style as hover menu(change the color).I have the css for both hover and current selected menu,and hover is working fine. I have googled this problem and solution was to set "class= current" in the li section of the html code.But my doubt is whether I have to set "class=current" each li sections or is there any need of javascript to report which one is selected out of the menu. I am newbie to css.Please help me..
<div id="tabsJ">
<ul class="menu">
<!-- CSS Tabs -->
<li><span>Reports</span></li>
<li><span>Employee</span></li>
<li><span>Equipment</span></li>
<li><span>Scanner</span></li>
</ul>
</div>
I have used this css
#tabsJ {
float:left;
width:100%;
background:#F4F4F4;
font-size:93%;
line-height:normal;
border-bottom:1px solid #24618E;
}
#tabsJ ul {
margin:0;
padding:10px 10px 0 50px;
list-style:none;
}
#tabsJ li {
display:inline;
margin:0;
padding:0;
}
#tabsJ a {
float:left;
background: url("../images/tableftJ.gif") no-repeat left top;
margin:0;
padding:0 0 0 5px;
text-decoration:none;
}
#tabsJ a span {
float:left;
display:block;
background:url("../images/tabrightJ.gif") no-repeat right top;
padding:5px 15px 4px 6px;
color:#24618E;
}
/* Commented Backslash Hack hides rule from IE5-Mac \*/
#tabsJ a span {float:none;}
/* End IE5-Mac hack */
#tabsJ a:hover span {
color:#FFF;
}
#tabsJ a:hover {
background-position:0% -42px;
}
#tabsJ a:hover span {
background-position:100% -42px;
}
#tabsJ #current a {
background-position:0% -42px;
}
#tabsJ #current a span {
background-position:100% -42px;
color:#FFF;
}
Sam Warren - Added jsfiddle - http://jsfiddle.net/ejLTy/
Actually I have this menubar in the masterpage for all the four pages,DataLog.aspx,EmployeeDetails.aspx,EquipmentDetail.aspx and ScannerDetail.aspx.
No Need of JavaScript. Just change li as,
<li class="current"><span>Reports</span></li>
<li><span>Employee</span></li>
<li><span>Equipment</span></li>
<li><span>Scanner</span></li>
for page DataLog.aspx. Use the same routine for all pages by changing the li class as current.
For hover use the pseudo element property in css called
your_division:hover
Hey Just put class="current" in first li. you will get selection on each link. And also
Go to following link, you will get different kind of menus as well as you can customize menu also as per your requirement.:
http://www.cssmenumaker.com/
check it the example of your updated CSS i have just added (current) id in your li
and where you want the selected link add the current id in that particular li.
http://jsfiddle.net/ejLTy/2/

CSS Block Position Question

I'm pretty new to CSS but I'm hoping this is just something obvious I'm missing.
On www.sonogenics.co.uk, the Twitter block appears to be floated to the right or have 40px left margin. I have explicity set the margins to be 0px and cleared the floats etc but there has been no effect. From the Firefox WebDeveloper addon, it appears to be a problem with the .tweet ul but I can't seem to fix it. Can someone explain to me what is going on?
Cheers
Chris
It actually has left-padding and not margin. This is the default styling of a ul element. To cancel it, you should put padding:0; in the #tweet ul style declaration.
A couple of suggestions:
Use Firebug for development, it is far superior to the WebDeveloper add-on. I was able to immediately spot the problem using it
Use a CSS reset stylesheet, to remove those default style declarations and normalize it across browsers (the defaults are not consistent between browsers). The best known is the CSS reset by Eric Meyer, which I personally use on every site I develop.
#chris robinson; i checked your twitter/style.css your main problem is that you declare css wrongly that why the properties are not working.
wrong css declaration :
.twitter #tweets {
background: #111;
padding: 0 0px;
padding-bottom:20px;
text-align:left;
-moz-border-radius: 5px;
border-radius: 5px;
border-color:#AAA;
border-style:solid;
border-width:2px;
margin:0px;
}
.twitter ul, li {
list-style-type: none;
background: #222;
-moz-border-radius: 5px;
border-radius: 5px;
border-color:#AAA;
border-style:solid;
border-width:1px;
padding-left:0px;
padding-right:0px;
padding-bottom:0px;
margin:0px;
-webkit-padding-start:10x;
}
.twitter #tweets a {
color: #AAA;
text-decoration:none;
}
.twitter #tweets a:hover {
color: #AAA;
}
if you check your html your twitter class is inside #tweets not outside of it . So, first correct your css .
Correct css:
#tweets .twitter {
background: #111;
padding: 0 0px;
padding-bottom:20px;
text-align:left;
-moz-border-radius: 5px;
border-radius: 5px;
border-color:#AAA;
border-style:solid;
border-width:2px;
margin:0px;
}
#tweets ul.twitter li {
list-style-type: none;
background: #222;
-moz-border-radius: 5px;
border-radius: 5px;
border-color:#AAA;
border-style:solid;
border-width:1px;
padding-left:0px;
padding-right:0px;
padding-bottom:0px;
margin:0px;
-webkit-padding-start:10x;
}
#tweets .twitter a {
color: #AAA;
text-decoration:none;
}
#tweets .twitter a:hover {
color: #AAA;
}
This should fix it
#tweets ul { padding: 0px; }
uls have a left padding by default in most browsers (i.e. WebKit 40px).
Your styling isn't being applied because of your css selector. Your selector is
.twitter ul, li {}
while your html for the elements are
<div id="tweets">
<ul class="twitter">...</ul>
</div>
Your css selector says "style all ul and li that are descendents of any element with the 'twitter' class". Since the ul isn't contained in an ancestor element with the "twitter" class, it isn't being styled with that rule.
If you want the rule to actually apply, you can either just use the selector
.twitter {...}
or you can re-class the parent div with "twitter",
<div id="tweets" class="twitter">
<ul class="twitter">...</ul>
</div>
or you can use this selector instead,
#tweets ul, li {...}
which more closely matches your original selector.

List Items turned into float:left blocks look strange in IE6

I have a UL that looks like this:
<ul class="popular-pages">
<li>California</li>
<li>Michigan</li>
<li>Missouri</li>
<li>New York</li>
<li>Oregon</li>
<li>Oregon; Washington</li>
<li>Pennsylvania</li>
<li>Texas</li>
<li>Virginia</li>
<li>Washington</li>
</ul>
And CSS that looks like this:
ul.popular-pages li a {
display:block;
float:left;
border-right:1px solid #b0b0b0;
border-bottom:1px solid #8d8d8d;
padding:10px;
background-color:#ebf4e0;
margin:2px; color:#526d3f
}
ul.popular-pages li a:hover {
text-decoration:none;
border-left:1px solid #b0b0b0;
border-top:1px solid #8d8d8d;
border-right:none;
border-bottom:none;
}
So it's working fine in modern browsers, but it's looking like this in IE6. Any suggestions?
The reason for your layout is probably because you have the float on the anchor, move it to the list-item instead.
ul.popular-pages li {
float: left;
}
Since you're not setting any width in your LI's, I suggest skipping the float and set display: inline on your LI's instead, if you want them on a row.
Adjust with padding/margin to get appropriate spacing between them, and line-height to get correct behaviour for any eventual 2nd line.
That way you won't have problem with your UL not taking up space, without the need of a hidden clear-element at the end of the list (which is your other alternative)
What DOCTYPE are you using? DOCTYPE has an impact on how browsers render.
try use this CSS hack for IE6.
*html ul.popular-pages li a {
display:block;
float:left;
border-right:1px solid #b0b0b0;
border-bottom:1px solid #8d8d8d;
padding:10px;
background-color:#ebf4e0;
margin:2px;
color:#526d3f
}
*html ul.popular-pages li a:hover {
text-decoration:none;
border-left:1px solid #b0b0b0;
border-top:1px solid #8d8d8d;
border-right:none;
border-bottom:none;
}
then adjust your CSS definition for IE6
You're floating your elements, so their parent needs to clear/reset the flow via the clearfix 'hack'.

Resources