How is the CSS Selector & and > used inAngularJS CSS - css

I have a css file. In my rails project I could something like this in my css file
.ls-brighter {
font-weight:bold;
font-size:12px;
background-color: #FF6600;
padding: 1%;
font-style:italic;
& > span {
color:red;
font-size:1.6rem;
}
}
but if i try it in AngularJS css file, it always returns a lexical error.
How are CSS selectors used in AngularJS?

.ls-brighter {
font-weight:bold;
font-size:12px;
background-color: #FF6600;
padding: 1%;
font-style:italic;
& > span {
color:red;
font-size:1.6rem;
}
}
This is not CSS, this is Sass. & and nesting are not used in CSS.
Try this CSS version :
.ls-brighter {
font-weight:bold;
font-size:12px;
background-color: #FF6600;
padding: 1%;
font-style:italic;
}
.ls-brighter > span {
color:red;
font-size:1.6rem;
}

Related

How to extend a class in LESS on hover

Hi I was wondering how I can take styles from another class on a hover state in LESS.
At the moment I have:
.language .active {
background:#de1f24;
color:#ffffff;
padding:7px;
text-align:center;
border-bottom: solid 1px #3A3838;
display: inline-block;
border-bottom-left-radius: 4px;
border-bottom-right-radius:4px;
font-weight:bold;
}
.language a {
color:red;
font-weight:bold;
}
&:hover{
&:extend(.language);
}
.fontSize{
font-size:22px;
}
.box{
color:#fff;
width:50px;
height:50px;
background:red;
font-size:14px;
&:hover{ /*This will add Hover effect to .box */
.fontSize; /*This will inherit the style from the .fontSize class*/
background:blue;
}
}
Codepen Demo : http://codepen.io/anon/pen/rHghJ
I am not sure I understood a question. But try using this construction
.language a {
color:red;
font-weight:bold;
&:hover {color:blue;}
}
.language-2 a {
.language a:hover;
}

css pagination highlight the chosen page number

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;
}

How to override a part of the style in the site.master page?

I am developing an ASP.NET web application which in its site master (in the ContentPlaceHolder3) I put some css style which should apply to the whole website. Part from this style is the following:
.Welcome {
width:531px;
margin:5px 15px;
float:left;
padding:5px 10px;
}
.Welcome ul {
width:250px;
float: left;
margin:5px 3px;
padding:0;
list-style:none;
}
.Welcome li {
background:url(images/ul_li.gif) left no-repeat;
padding:5px 20px;
margin:0;
font: normal 12px Georgia, "Times New Roman", Times, serif; /* the original font-size was 11px. */
color:#5c5c5c;
}
Now, in one of the website pages, I want to put some content inside that ContentPlaceHolder with the following specific style:
/*body { font: 0.8em Arial, sans-serif; }*/
.tipsMenu { padding: 0; clear: both; }
.tipsMenu li { display: inline; }
.tipsMenu li a { background: #ccf; padding: 10px; float:left; border-right: 1px solid #ccf; border-bottom: none; text-decoration: none; color: #000; font-weight: bold;}
.tipsMenu li.active a { background: #eef; }
.tipsContent { float: left; clear: both; border: 1px solid #ccf; border-top: none; border-left: none; background: #eef; padding: 10px 20px 60px; width: 400px; }
EDIT:
*When I tried to do it, I got some style from the CSS file that is in the site.master page. So how can I override the style in the master page with the inline style?*
Apart from making sure the specific style is loaded after the one embedded in the site.master page, you can try a couple of things:
1. Check the css specificity of your new styles. Basically you need to make sure that the selectors used in your new styles are more specific than the ones used in the other stylesheet. In short, inline styles are more specific than ids, ids are more specific than classes and classes are more specific than html elements. e.g.:
#selector {
// High specificity
}
.selector1 .selector2 .selector3 {
// Less specificity than #selector, #selector styles applied
}
2. Add the !important clause to the styles. This overrides the specificity rules and forces the browser to use the important style. Although easier, this method isn't recommended for the sake of maintainability, among other reasons. like this:
.tipsMenu { padding: 0 !important; clear: both !important; }
.tipsMenu li { display: inline !important; }

CSS code customization

I am an iPhone App Developer and have very very little knowledge about css.I have a code to create a no of cells.here this is:
<style type="text/css" media="screen">
body {
margin: 0;
width: 320px;
height: 200px;
}
.ad-carousel-view .cells > li {
width: 200px;
height: 70px;
padding-top: 16px;
padding-left: 20px;
color: white;
font-size: 20px;
font-family: "Helvetica Neue", Helvetica;
-webkit-border-radius: 10px;
-webkit-box-sizing: border-box;
background-image:url('13.jpg');
}
.ad-carousel-view .cells > li:nth-child(odd) {
background-color: rgb(255,59,59);
}
.ad-carousel-view .cells > li:nth-child(even) {
background-color: rgb(80,80,80);
background-image:url('13.jpg');
}
.ad-carousel-view .cells > li.active {
background-color: red;
background-image:url('23.jpg');
}
</style>
<style type="text/css">
.wrap{
border:solid 1px #000000;
width:320px;
height:150px;
position:relative;
top:0px;
left:0px;
}
</style>
in the above code the following section is used to set cell's BG color and image
//odd cell
.ad-carousel-view .cells > li:nth-child(odd) {
background-color: rgb(255,59,59);
}
//even cell
.ad-carousel-view .cells > li:nth-child(even) {
background-color: rgb(80,80,80);
background-image:url('13.jpg');
}
//highlighted cell
.ad-carousel-view .cells > li.active {
background-color: red;
background-image:url('23.jpg');
}
now what i need is to change BG image dynamically...i mean instead of using
background-image:url('23.jpg');
i want use variable something like
background-image:url(var);
is it possible in CSS??....if no then can anyone have any idea to dynamically set image name??
It's not possible in pure CSS. You could use Javascript to set the background-image property on load:
jQuery example:
$(document).ready(function(){
$('.ad-carousel-view .cells > li.active').each(function(){
var img = getYourImagePath();
$(this).css({backgroundImage: img});
});
});
You can do this in your HTML if you're using a server-side technology by using an inline style, so on your element you'd have something like:
<li class="active" style="background-image:url(###);"></li>
where you would replace ### with whatever output method you're using to dynamically set the image.
You can also set it with javascript if you don't have any server-side technology to work with:
var obj= document.getElementById('aUniqueId');
obj.style.backgroundImage = yourImage;
jQuery is similar but a little nicer because it can pick up the class instead of just the ID - which would be better if you want to apply more than one active class on the page:
$(".active").css("backgroundImage",yourImage);
Yes this should be fine. Have you tested it? I'm sure it works OK.
The LESS allows you to use variables in the CSS :)
Example:
#brand_color: #4D926F;
#header {
color: #brand_color;
}
h2 {
color: #brand_color;
}

I want this nav inline in IE 7 & IE 6

I have following CSS for that
/* Start Submenu */
#submenu {
list-style-type:none;
}
#submenu ul{
border-bottom:3px solid #1c29da;
margin:0px;
padding:0px;
display:table;
}
#submenu li{
width:123px;
height:58px;
background:url(submenu_btn.jpg) no-repeat;
vertical-align:middle;
text-align:center;
display:table-cell;
}
#submenu a {
color:#333333;
font: bold 12px/13px Arial, Helvetica, sans-serif;
cursor:pointer;
}
#submenu a:hover {
color:#2f6535;
font: bold 12px/13px Arial, Helvetica, sans-serif;
cursor:pointer;
}
/* End Submenu */
See this image. What is the solution for IE 6 & 7 for making it inline?
The standard cross-browser implementation is to use floats. Start with something like:
#submenu { overflow: hidden; }
#submenu ul { overflow: hidden; }
#submenu li { float: left; }
and style as required.
That being said, I wouldn't roll your own solution to this. There are lots of exceptions and code required for certain browsers. This is only the beginning of your problems. I'd recommend using a prepackaged tab or menu solution instead.

Resources