How do create a styleClass for the following CSS? I want it only to be used in one particular section of the form - the tabbed menu - and not affect anything else. If I leave it as is, everything on the form is affected by it.
a:link,a:visited
{
display:block;
width:120px;
font-weight:bold;
color:#ffffff;
background-color:#5576A7;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
a:hover,a:active
{
background-color:#ff9c2a;
}
You need to add a class to your link, and reference that in your CSS.
With the markup:
My Link
And with the CSS:
a.myClass:link,a.myClass:visited
{
display:block;
width:120px;
font-weight:bold;
color:#ffffff;
background-color:#5576A7;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
a.myClass:hover,a.myClass:active
{
background-color:#ff9c2a;
}
You can set a class in html like this:
hello world
And then you can limit the styles to this class in css like this:
a.someclass:link, a.someclass:visited {
...
}
a.someclass:hover, a.someclass:active {
...
}
You'll need to add a class or ID to do so.
For you tab you can use an ID like this:
<div id="specialTab">
Lorem Ipsum
</div>
and change your CSS like this:
#specialTab a:link, #specialTab a:visited
{
display:block;
width:120px;
font-weight:bold;
color:#ffffff;
background-color:#5576A7;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
#specialTab a:hover, #specialTab a:active
{
background-color:#ff9c2a;
}
There are two ways.
1) Give each element a class ("tab" in this case):
a.tab:link, a.tab:visited { ... }
2) Use a container group. Say your tab menu has id "tabMenu":
#tabMenu a:link, #tabMenu a:visited { ... }
I would put the menu in a div with the id 'menu'
Then just
#menu a:link, #menu a:visited
{
display:block;
width:120px;
font-weight:bold;
color:#ffffff;
background-color:#5576A7;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
#menu a:hover,#menu a:active
{
background-color:#ff9c2a;
}
If you like to style just a section in a form part you can give this section an Id like here:
<form>
<fieldset>
<ul>
<li id="style-me"> </li>
<li> </li>
</ul>
<fieldset>
</form>
#style-me a:link, #style-me a:visited
{
display:block;
width:120px;
font-weight:bold;
color:#ffffff;
background-color:#5576A7;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
a:hover,a:active
{
background-color:#ff9c2a;
}
To apply styles on specific parts of your html you must use selectors:
First add div or other tag with unique id set around elements you need to change.
<div id="zone_name">
link
<span>text</span>
</div>
In style add id selector and tag name
#zone_name a {
/*style attributes for a tag in zone_name*/
}
#zone_name span {
/*style attributes for span tag in zone_name*/
}
With specificity, either assign a class or use the class of closest parent to style your <a> tags. e.g.
.tabbed-menu a:link, .tabbed-menu a:visited {
display:block;
width:120px;
font-weight:bold;
color:#ffffff;
background-color:#5576A7;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
.tabbed-menu a:hover, .tabbed-menu a:active {
background-color:#ff9c2a;
}
Where .tabbed-menu would be the class used by your menu.
Related
I have this CSS :
<style>
#web_pagination_number {
float:left;
position:relative;
width:35px;
height:35px;
line-height:35px;
background-color:#111111;
font-family:Arial;
font-size:14px;
color:#ffffff;
text-align:center;
}
#web_pagination_number:hover {
color:#111111;
background-color:#93CF25;
}
#web_pagination_number a {
text-decoration:none;
color:#ffffff;
}
#web_pagination_number a:hover {
text-decoration:none;
color:#111111;
}
</style>
The problem i have it´s when i go over web_pagination_number , change the color of background of this div but no the color of the link , the link color only change when i go over the link
I don´t know how i can fix this
Thank´s , Regards
You need to add :hover to your web_pagination_number id, like this:
#web_pagination_number:hover a {
color: #333;
}
Just add a property display: block on a
Demo
I am looking for a way to highlight the chosen page number in pagination using css,
or to make the chosen page number bold.
the pagination php code works fine so I think I should modify the css page.
what should I add here:
body
{
padding:50px;
font-size:0.85em;
font-family:arial;
}
a
{
text-decoration:none;
color:#0080ff;
}
a:hover
{
text-decoration:underline;
}
.info
{
line-height:150%;
width:650px;
overflow:auto;
margin-top:30px;
color:#555555;
}
.msg
{
padding:10px;
border-bottom:dashed 1px #5d478b;
width:450px;
margin-bottom:15px;
}
#pages
{
clear:both;
list-style-type:none;
overflow:hidden;
margin:0;
padding:0;
}
#pages li
{
float:left;
}
#pages li a
{
font-weight:bold;
margin:0 4px;
padding:5px 10px;
border:1px solid #bbb;
display:inline-block;
border-radius:5px;
}
#pages li a:hover
{
text-decoration:none;
color:#ff0080;
}
You are missing information in your post about the html produced for the pagination.
I presume from your CSS that each page link is an anchor within a list item within an element with the id pages. I'm going to assume that the selected anchor has some sort of class on it, let's say "selected". Add something like this to your css:
#pages li a.selected
{
font-weight: bold;
background-color: yellow;
}
What would be the best way to add an active class on this css for my menu?
.vertical-nav{
width:200px;
height:auto;
list-style:none;
float:left;
margin-right:40px;
}
.vertical-nav li{
width:200px;
height:25px;
margin:5px;
padding:5px;
background-color:#666666;
border:none;
text-align:center;
float:left;
}
.vertical-nav li:hover{
background-color:#f36f25;
color:#FFFFFF;
}
.vertical-nav li a{
font-family:Calibri, Arial;
font-size:18px;
font-weight:bold;
color:#ffffff;
text-decoration:none;
}
I would add it on .vertical-nav li:active { }
this way you can modify both the <li> and the <a> properties
It depends on how you want the 'current' list item to display,
Personally I would always apply to the class to the li, and so it would give you something like:
.vertical-nav li.active {
background-color:#D9A300;
}
and to style the link inside that you would
.vertical-nav li.active a {
color:#000000;
}
I would actually suggest using the term 'current' rather than 'active' as it is easy to misunderstand.
I may of misunderstood what you're requesting.. if i have, let me know and i will amend my answer accordingly.
This is my CSS:
/* Navigation Bar */
#linkBar
{
position: relative;
overflow: hidden;
height:24px;
width:999px;
background:#990033;
}
.linkbar ul
{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
.linkbar li
{
float:left;
}
.linkbar a:link,a:visited
{
font-size: 14px;
display:block;
width:134px;
font-weight:bold;
color:#FFFFFF;
background-color:#990033;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
.linkbar a:hover,a:active
{
background-color:#000000;
}
/* Links */
a:link,a:visited,a:active
{
font-size: 8pt;
font-weight:bold;
color:#990033;
text-decoration:underline;
}
a:hover
{
color:#0000FF;
text-decoration:none;
}
My expected outcome is that links show like:
Which is the case for most of the elements, however the first link on the linkbar ends up like:
Linkbar code:
<div id="linkBar" class="linkbar">
<ul>
<li>Home</li>
<li>Course</li>
<li>Help</li>
</ul>
</div>
I've made a jsfiddle for this
(on jsfiddle i dont get the problem with the first link in the linkbar, so this implies its a problem with the rest of my code?).
I can solve the issue with the navbar if i just change the css around to be:
#linkBar
{
position: relative;
overflow: hidden;
height:24px;
width:999px;
background:#990033;
}
/* Links */
a:link,a:visited,a:active
{
font-size: 8pt;
font-weight:bold;
color:#990033;
text-decoration:underline;
}
a:hover
{
color:#0000FF;
text-decoration:none;
}
/* Navigation Bar */
.linkbar ul
{
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
}
.linkbar li
{
float:left;
}
.linkbar a:link,a:visited
{
font-size: 14px;
display:block;
width:134px;
font-weight:bold;
color:#FFFFFF;
background-color:#990033;
text-align:center;
padding:4px;
text-decoration:none;
text-transform:uppercase;
}
.linkbar a:hover,a:active
{
background-color:#000000;
}
But this then means that the visited normal links text color is white - which is not what I want (as some normal links are on light or white backgrounds).
I've made a jsfiddle for this (visited links being white).
Can anyone see what I'm doing wrong / point me in the direction of how to fix it?
Where you have written .linkbar a:link,a:visited you need to repeat the classname before a:visited
Right now you are actually saying '.linkbar link, and then override all a:visited'
So it should be .linkbar a:link, .linkbar a:visited { .. }
I use two different a:link/a:visited/a:hover tags.. But the links in .panel take over the a:link/a:visited from .footer and only gets a:hover from .panel right.
HTML
<div class="panel" id="tab4"><b>Title – Name</b>
CSS
.panel a:link, a:visited {
color:#333;
text-decoration:none;}
.panel a:hover {
color:#000;
text-decoration:none;
border-bottom:1px solid #000;}
.footer a:link, a:visited {
color:#fff;
text-decoration:none;
opacity:0.8;
filter:alpha(opacity=80); /* For IE8 and earlier */}
.footer a:hover {
color:#fff;
text-decoration:none;
border-bottom:1px solid #fff;
opacity:1.0;
filter:alpha(opacity=100); /* For IE8 and earlier */}
CSS rules are a comma delimited list which are parsed by the browser right to left, top to bottom. When you do the following:
.panel a:link, a:visited{
/*things*/
}
.footer a:link, a:visited {
/*more things*/
}
The browser is saying:
"Ok, step one, for any anchor which is visited, do these rules. Then for any anchor link with a class of panel, do these same rules."
"On to step two, for any anchor which is visited, do these second rules {over writing your step one}, and for anything with the class of footer, do these second rules again."
So, make sure you have enough CSS specificity to correctly target what you're looking to target.
You declare a:visited twice, and the latter overwrites the values of the first.
.panel a:link, .panel a:visited {
color:#333;
text-decoration:none;
}
.footer a:link, .footer a:visited {
color:#fff;
text-decoration:none;
opacity:0.8;
filter:alpha(opacity=80); /* For IE8 and earlier */
}
This is probably what you are looking for. You can specify comma-delimited targets, but each one must by fully specified. Otherwise it would read like:
.footer a:link {
<declarations>
}
a:visited {
<declarations>
}