JQM and CSS overrides - html

I am using a nav element to create a menu. I am also using JQM to format a listview. The CSS of the JQM overrides the nav style and I simply cannot understand why.
This is my nav element with link elements:
<nav>
<ul>
<li>New</li>
<li>Update</li>
</ul>
</nav>
And this is the CSS for the link elements inside the nav element:
nav > ul > li > a {
color: #aaa;
background-color:#333;
display: block;
line-height: 2em;
padding: 0.5em 0.5em;
text-decoration: none;
}
The color attribute is overridden by the JQM stylesheet (turning out blue). The specific overriding setting has been identified as:
.ui-page-theme-a a:visited, html .ui-bar-a a:visited, html .ui-body-a a:visited, html body .ui-group-theme-a a:visited {
color: #38c;
}
What I don't understand is why is it being overridden? The JQM style has some specific classes which I didn't specify in my nav element, so why am I losing the color settings? Why is the JQM style applied to my non-classed link/nav?
NB: I am complete noob when it comes to these things, so excuse my plain ignorance

The JQM styles are probably added by it's script. As soon as you initiate the element, it gets the classes assigned to it.
The reason that it overrules is because the selector is more specific. If you want to read more about specificity, follow this link.
If you want to overrule the JQM style, you have a few options
Quick and dirty
Use the !important rule, it overrules all other styles
nav > ul > li > a {
color: #aaa !important;
background-color:#333;
display: block;
line-height: 2em;
padding: 0.5em 0.5em;
text-decoration: none;
}
Latter rule
Use the same selector, but be sure that your stylesheet is loaded after the JQM stylesheet
.ui-page-theme-a a:visited,
html .ui-bar-a a:visited,
html .ui-body-a a:visited,
html body .ui-group-theme-a a:visited {
color: #aaa;
}

Related

CSS - computed style over declared style

I made an application in ExtJS 6, a have made a menu and made the menu items as links. The colors changed to the default link colors, so I wanted to change them to black. I wrote a CSS and it works it loads, in Chrome in the Elements panel in Styles menu it shows that it's the active style. But when I check the Computed menu, it shows me that color is rgb(85, 26, 139). I can even expand it, where it shows me this:
The css which contains the styling is added last, I tried almost everything which comes in my mind.
Something should be with the hyperlinks, because there are some menu items which arent used as links and the styling works on them well.
Any idea what can I do with it?
Thanks in advance!
Edit:
My css style:
.menu-item a:link, .menuItem a:visited, .menuItem a:hover, .menuItem a:active {
color: #222222 !important;
text-decoration: none;
}
Have you tried styling the the .menu-item a to #222222; and
.menu-item a:not([href]) { color:rgb(85,26,139);}
.menu-item a, .menu-item a:link, .menuItem a:visited, .menuItem a:hover, .menuItem a:active {
color: #222222;
text-decoration: none;
}
.menu-item a:not([href]) {
color:rgb(85,26,139);
}
Like this: https://jsfiddle.net/Harvey89/164opbL4/3/
Probably best not to use !important

Trouble with selectors in CSS

I'm pretty new to using CSS, and have been working on some WordPress template projects. I feel like this is a very simple problem that I've run in to, but I can't find documentation or previous questions that answer it for me, my apologies if they are out there!
What I'm trying to do is format a <ul> and links within that list in a specific way. That <ul> comes from the "Pages" widget in WordPress, and lives in
<aside id="pages-2" class="widget widget_pages">
which is in
<div id="secondary" class="widget-area" role="complementary">
In my style sheet, I've added these lines:
.widget-area ul {
list-style-type: none;
}
.widget-area a {
color: black;
}
.widget-area a:visited {
color: red;
}
.widget-area a:hover,
.widget-area a:focus,
.widget-area a:active {
color: midnightblue;
}
However, the elements are still styled in the way the ul and a elements are styled without the specificity of the .widget-area. I have had success with these lines though:
.widget-area {
position: fixed;
max-width: 247px;
}
Any help is greatly appreciated!
The site is here: http://ccarrollmusic.com/
With CSS there are a few reasons this could be happening,
Your changes might be getting overwrote by a class or id style on the element having the !important attribute.
Your file could be loading before the Wordpress CSS file that is setting those styles in the first place
What I guess is most likely is there is a more specific rule which is taking over.
It's best to do something like:
#secondary .widget-area ul li a:hover,
#secondary .widget-area ul li a:focus,
#secondary .widget-area ul li a:active {
color: midnightblue;
}
You can successfully target the ul in the widget in question by using the id of the aside that is its' immediate parent:
aside#pages-2 ul li a {
color: pink;
}
I've actually been able to solve this by simply using .widget-area ul, however I moved it up in the style sheet so that it comes directly after I stle .widget-area and that seems to have done the trick. Earlier, there was mention of .page_item between .widget-area and .widget-area ul. Is there importance as to the order of style declarations and specificity? Because I didn't think that would be important I didn't include it in the original question, sorry about that!

Bootstrap "jumbotron-narrow" example. how does the style change?

I'm going over the bootstrap site example http://getbootstrap.com/examples/jumbotron-narrow/#
and when I hover my mouse over the "About" or "Contact" links a grey rounded box appears around the text. When the mouse leaves the element, the grey rounded box disappears.
This is driving me crazy! I have inspected these elements and gone through the styles applied to them and have gone through every single one of them, all the inherited ones, the whole lot. Can someone go through the css and tell me exactly how this is happening? I expected to find some sort of :hover or :focus css but none exists. Furthermore it is not javascript that is changing the background as I have tested the site with javascript enabled.
Please help and I will love you forever.
The code you are looking for:
.nav > li > a:hover, .nav > li > a:focus {
text-decoration: none;
background-color: #EEE;
}
Super simple, fix:
<link bootstrap />
<link custom /> <-- Overwrite CSS by placing external file after in HTML
Or:
<link bootstrap />
<style></style> <-- Overwrites bootstrap's external CSS
CSS to change is simple:
.nav > li > a:hover, .nav > li > a:focus {
background-color: none;
}
Why does Bootstrap make it so if you hover, it turns grey?
It is because it tells the visitors, that they are on something clickable: a link. And making it more user-friendly and improves a website's UX.
There are an CSS applied when you hovered these elements -
.nav>li>a:hover, .nav>li>a:focus {
text-decoration: none;
background-color: #eee;
}
Please see highlighted in red -
Demo
html
<ul class="nav">
<li> About
</li>
</ul>
css
.nav>li>a:hover, .nav>li>a:focus {
text-decoration: none;
background-color: #eee;
}
.nav>li>a {
position: relative;
display: block;
padding: 10px 15px;
border-radius: 4px;
text-decoration:none;
width:50px;
text-align:center;
}
.nav {
list-style: none;
}
The buttons background turns grey because of the following css in the bootstrap.min.css file:
nav>li>a:hover,.nav>li>a:focus{text-decoration:none;background-color:#eee}
You can run a find on the code mentioned before to find it in the bootstrap.min.css file.

Style styling links that it shouldn't be

I have a style that is styling the links on the navigation bar, but it styles all other links in the website, so I defined the div "menubar" as the selector infront of the link and visited selectors but it still styles all links in the website. Any solutions would be greatly appreciated.
CSS:
#menubar a:link, a:visited
{
border-top-width: 1px;
display: block;
font-weight: bold;
color: #000000;
background-color: #EFF1EB;
width: 180px;
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
border-style: solid;
border-color: #638529;
font-family: Arial, Helvetica, sans-serif;
border: 1px;
position: fixed;
}
Your selector is wrong, change to this one:
#menubar a:link, #menubar a:visited /* width #menubar after the comma */
Your initial selector, #menubar a:link, a:visited means: "all links in #menubar and all visited links in the entire document". The comma starts a completely new selector so you have to include the parent also in the second selector.
I think #Yotam is right.
Another idea how to debug this. I use Web Development Toolbar inside Firefox. It has plenty of tools, one is to inspect the page. Use the one to see the style ( I like the 3D View), there you can press on the html element, in your case the link. Next to the page, it lists the style sheet definitions . The order shows what is the active style. Top is active, and everyhing else is lower and overwritten.
In this case, you may see, if your button has the correct definitions you want.

How to change color of visited row of the list using css in html

I have taken the links dynamically which are coming in a list. When i click on the link, in other container its page opens. I want to change the visited link color.Basically the block background color. I am able to change color on click. but i need it will stay as it is until n unless i refresh the page. I used
ul
{
list-style-type: none;
margin:0;
padding:0;
text-decoration:none;
display: block;
}
a {
text-decoration: none;
display: block;
}
ul li{
padding-bottom: 10px;
text-decoration: none;
}
li:hover {
background-color:#7EA5E4;
}
li a:visited, a:active{
background-color: #09F;
}
Please suggest me where i have to do changes.
That is, what :visited does. But you "block" is the list item, which can't be visited, because it isn't a link. Style you anchor as block by moving the appropriate styles from the list item to the anchor. That way you also could style the background.
You could try something like, changing the colour / font family to suite you
.Link A:visited {
text-decoration: none;
font-family: arial,sans-serif ;
color: #fff;
}
The .link is a custom class
Hope this can help,
Thanks,
Jack.
i hope you are looking like this:- http://tinkerbin.com/VsbhpxGi
you just have to make .active class and define in li
like this :-
li.active {
background-color:#7EA5E4;
}
UPDATED ANSWER
i hope you are looking like this if you will click on any link so that link will be active...... see the updated answer...
http://tinkerbin.com/Fm0lRO8Z